databaseprimary-keyrelationcandidate

What is the candidate key, and the primary key?


I have two tables:

tblTrip (primaryKey: tripNo)
tblPerson (primaryKey: personID)

the relation between these 2 tables is n:n

so there is a relational table: tblParticipateIn (tripNo, personID...)

1- what is the candidate key of the table?

2- what is the primary key of the table?


Solution

  • The primary key in tblParticipateIn is: tripNO and personID Since both in combination have to be unique

    The candidate key are both: tripNO and personID, they are both optional as a primary key.

    Read this for more info:

    http://blog.sqlauthority.com/2009/10/22/sql-server-difference-between-candidate-keys-and-primary-key-2/