0

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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Hanin
  • 33
  • 5

3 Answers3

1

It's impossible to answer your question completely without knowing the columns you've left out--the ones represented by ...--and their dependencies.

In most cases, the pair of columns {tripNo, personID} is one candidate key; there might be more candidate keys. The pair of columns {tripNo, personID} is the most likely primary key.

Mike Sherrill 'Cat Recall'
  • 91,602
  • 17
  • 122
  • 185
0

ans1-tripNo,personID both are candidate key ans2-tripN

  • You are wrong, the combination of tripNO and personID in the tblParticipateIn is the primary key. They both have to be unique together. It is an n-n relation – Revils Sep 12 '14 at 13:04
-2

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/

Revils
  • 1,478
  • 1
  • 14
  • 31
  • What I can say about each one of the keys separately in tblParticipateIn ? tripNo for example, can I say it's a candidate key – Hanin Sep 12 '14 at 13:07
  • tripNO and personID are both seperately foreign keys. They refer to the table where they are primary in. So tripNO refers to tblTrip and personID refers to tblPerson. However combined they are also the primary key for tblParticipateln – Revils Sep 12 '14 at 13:09
  • @Hanin & Sliver2009: This answer doesn't make sense, since it contradicts itself, saying that the combination is a PK and that each can be a PK. But both statements are wrong anyway, see Mike Sherrill 'Cat Recall''s answer. Also the link is wrong: a CK must be a unique column set that does not contain a smaller unique column set. (Although an SQL PK [sic] declaration actually only declares uniqueness, not a CK or PK in the relational sense.) – philipxy Sep 20 '14 at 23:01
  • it kind of makes sense, you just don't agree with it. Maybe the CK is wrong, but The primary key is true though. – Revils Sep 21 '14 at 09:51