composite primary keys

Blue-Apple

New member
Local time
Today, 22:17
Joined
Feb 22, 2005
Messages
6
Is it possible that a composite primary from table A to be a foreign key in table B?
I have two tables: A and B. The A has some personal details such as first name, surname, phone number, etc.
Since no personal ID is given in my project, I am thinking to use first name + surname as the primary key of table A. But when I wanted to make the relationship between A and B (in B I need to use these 2 name fields as the composite primary keys, too) and ticked the option “enforce referential integrity”, an error message prompted out said it could not find the only primary key in table A.

What should I do with this? Or it is impossible to have a composite primary key to be foreign keys (but also primary) in another table?

It will be great if someone could answer this!
Thanks!
 
yes you can have composite primary key, used as a composite foreign key in another table..
I guess you didnt select both the fields while building the relationship in the design wizard,
..
You have to select both fieldnames within the primary key and also within the table using this primary key as a foreign should contain both the fields.

try it
 
But, gogaak, the data suggested for the PK could easilly be non-unique. Composite keys based on free entry data fields get you into trouble, sooner or later.
 
neileg said:
But, gogaak, the data suggested for the PK could easilly be non-unique. Composite keys based on free entry data fields get you into trouble, sooner or later.

Good to point out that...
But i was trying to point out that mistake to Blue, that you can have what he wants...but only the method is different.

And ya...identification number is the safest identifier in order to uniquely differentiate between each instance of any entity. So its better to go for some unique ID , instead of name..
 

Users who are viewing this thread

Back
Top Bottom