Re: primary key in a hierarchy
Date: Wed, 29 Nov 2000 11:02:29 +0100
Message-ID: <3A24D435.CF32137A_at_capgemini.fr>
In the case I work on, the "number" has a meaning : it is the identifier of the B elt for its A elt.
The first way seems to be better for indexes creation. Is'nt it ?
Jan Hidders a écrit :
> 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:
>
> 1. 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.)
>
> 2. Foreign key references to B will consist of just one attribute.
>
> --
> Jan Hidders
Received on Wed Nov 29 2000 - 11:02:29 CET