primary keys in sqlite

Discussion in 'iOS Programming' started by Jayage, Nov 27, 2009.

  1. macrumors newbie

    Nov 27, 2009
    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?!
  2. macrumors 6502a


    May 26, 2005
    Rampaging Tokyo
    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.

  3. macrumors member

    Jun 24, 2009
    and just incase your next question is what is a PK and FK
    PK = primary key
    FK = foreign key

Share This Page