Re: primary key in a hierarchy
From: Jan Hidders <hidders_at_REMOVE.THIS.win.tue.nl>
Date: 28 Nov 2000 16:40:38 GMT
Message-ID: <900n66$2h1$1_at_news.tue.nl>
Date: 28 Nov 2000 16:40:38 GMT
Message-ID: <900n66$2h1$1_at_news.tue.nl>
Christophe Geraud wrote:
> Hi,
>
> I have a hierarchy : one element of a table A has a relationship with
> 1..n elements of a table B, and one element of the table B has in
> relationship with one and only one element of the table A.
>
> The table A has a primary key named : ID_A (from a sequence)
> I know two ways to create the primary key for the table B :
> 1. ID_B (independant of ID_A)
> 2. (ID_A, Number)
>
> Is one of the two ways better ?
Not really IMHO, but I would prefer the first one for two reasons:
- You are not introducing an extra column that has no meaning for the user. (If the column 'Number' was already there then I would take the second solution.)
- Foreign key references to B will consist of just one attribute.
-- Jan HiddersReceived on Tue Nov 28 2000 - 17:40:38 CET