Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Many to Many link tables, without PKey defined?

Status
Not open for further replies.

Crowley16

Technical User
Jan 21, 2004
6,931
GB
Just wanted your opinions on whether it's really needed to define a Primary key in a Many to Many Link table, and why...

Personally, I don't see a need to define a PKey in there, but I could be missing something. Plus, if there is a PKey, then it would probably be a composite of the 2 foreign keys, as I don't see the need to create a autonumber key either...

--------------------
Procrastinate Now!
 
You need the primary key (consisting of the 2 FKs) in the link table to aviod having the same record duplicated, which would have no meaning.
 
the composite consisting of the two FKs does not need to be a PK, but the composite does need at least to be unique, as pbrodsky pointed out, and the easiest way to do that is by declaring the composite as the PK

the autonumber is useless, and it would only be potentially useful if the table has child tables of its own



rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts May 8 2005)
 
cool...

forgot about the unique bit...

--------------------
Procrastinate Now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top