Relationships: Meaningful char code vs numeric primary key
Date: 14 Jun 2002 06:13:12 -0700
Message-ID: <aa4fa6ea.0206140513.39a3458d_at_posting.google.com>
I have been mulling over the following scenario for some time and have never come to a conclusion so would be interested in other's views & opinions.
As a trivial example, say you have the following two tables
User Nationality ---- ----------- Id (unique numeric PK) Id (unique numeric PK) Name Code (unique 4 character meaningful code, e.g. BRIT)Nationality Description (e.g. BRITISH)
Now if we have a n-1 relationship between these two tables I can never
decide which of the following three options I should use to implement
the relationship.
Option A : Numeric User.Nationality references the Nationality.Id
field
Option B : Character User.Nationality references the Nationality.Code
field
Option C : User contains the Nationality Code and Id where the Id is
The issues here that I can't make a decision on are that I believe the Id reference will be more efficient as it is numeric based as opposed to character based, but this will be a meaningless number within the User table, whereas if I include the meaningful code within the User Table then this be displayed from the User table without doing a join to the Nationality table.
Paul. Received on Fri Jun 14 2002 - 15:13:12 CEST