Surrogate foreign key
Oki so I have two tables: 开发者_Go百科person and person_email
PERSON
------
id (PK)
person_code (Unique key 1)
person_type (Unique key 1)
surname
forename
PERSON_EMAIL
------------
id (PK)
person_id (Unique key 1) (references person(id))
email_address (Unique key 1)
Is this correct??
or should it be:
PERSON_EMAIL
------------
id (PK)
person_id (references person(id))
person_code (Unique key 1)
person_type (Unique key 1)
email_address (Unique key 1)
Your second suggestion includes both the unique identifiers of the PERSON table. If you try to do this, sooner or later you will find these identifiers indicate two different rows. Furthermore, changing the person_code or person_type in the PERSON table would then require a matching update of the PERSON_EMAIL table. For these reasons, I would suggest your first version is better.
精彩评论