View Full Version : primary keys in sqlite

Nov 27, 2009, 08:31 AM
I've fully created my table with all its attributes, but i forgot to declare my primary key.

Looking at the FAQ's it doesn't say anything about altering a table to include a Primary key!

Its a restaurant database which includes the restaurant names, their addresses, cuisine, longitude and latitude.

Inside each restaurant has starters and main courses.

Any commands to make the cuisine the primary key?!

Nov 27, 2009, 08:48 AM
I'm not too sure you would want cuisine as your PK. What if you have multiple restaurants that have the same cuisine?

I would recreate the table, and have a restaurant_id column as your PK. (just a unique number).

Cuisine should also have it's own table, with a cuisine_id column as it's PK. Then the restaurant table would have a FK to the cuisine table.


Nov 28, 2009, 05:23 AM
and just incase your next question is what is a PK and FK
PK = primary key
FK = foreign key