SQL Server Performance

Primary Key required for "Junction table" ?

Discussion in 'Getting Started' started by Tricky, Jul 13, 2010.

  1. Tricky New Member

    I have a table which is purely used for creating many-to-many relationships, hence all fields are foreign keys of other tables. Should I still include a primary key for this table?
  2. ashish287 New Member

    so in short this is the master reference table..if I am getting it correctly. Yes, you can add one mroe column as auto increment primary key which will by default put the clustered index and will make search faster by arranging the data physically.
    you can choose the candidate from exisiting columns for index. For ex. the column which is being referred in most of the case
  3. Adriaan New Member

    You should never leave a table without a primary key; at the very least, every table needs a unique constraint.
    Without one, a table contains only a heap of disorganized and implicitly unreliable data.
  4. satya Moderator

  5. Tricky New Member

    Thanks All. I thought as much. I didn't design this table but stumbled across it and wondered why a PK had been left out. I thought it may have been intentional, given the nature of the data (all FK's for many2many relationships) but probably just oversight. I've added PK. Thanks again.
  6. satya Moderator

    That explains the reason, also make sure that you have optimized the plan in cache to take the new schema changes in the table.

Share This Page