primary keys in sqlite

Discussion in 'iPhone/iPad Programming' started by Jayage, Nov 27, 2009.

  1. macrumors newbie

    Joined:
    Nov 27, 2009
    #1
    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

    VanMac

    Joined:
    May 26, 2005
    Location:
    Rampaging Tokyo
    #2
    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.

    Enjoy.
     
  3. macrumors member

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

Share This Page