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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ER identifiy relationship question 1

Status
Not open for further replies.

joelwenzel

Programmer
Jun 28, 2002
448
Hello,

I have a table. Each row in the table can be defined by an automatically generated unique id number. The individual rows can also be defined by a group of column elements (which happen to be foreign keys).

My primary key is the unique id number but it is also possible for cols 1,2, 3... to be grouped as a primary key. Can I have both things labelled as primary keys at the same time or is this a bad practice? I ask because someone said that some of my relationships are identifying and that they should be labelled as such.
 
Can I have both things labelled as primary keys at the same time
No.

or is this a bad practice?
Yes.

The Primary Key is the field or combination of fields which serve to identify each row of the table. You don't want to be using two different expressions as identifiers in two different parts of your system and the database won't even let you try.

What you should do is define the unique ID as the Primary Key and then define the other columns as a composite Candidate Key. That way the database will prevent you entering a duplicate value in the unique ID or entering a duplicate combination in the other fields.

Geoff Franklin
 
ah...thanks. Forgot abotu the old Candidate key :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top