Re: Question on Primary Keys

From: Heinz Huber <Heinz.Huber_at_elbanet.co.at>
Date: Tue, 17 Oct 2000 08:15:14 +0200
Message-ID: <39EBEE72.6F875BCE_at_elbanet.co.at>


There is another problem regarding the orderline example: You often want the lines numbered sequentially from 1 to max. If you use a unique OrderLineID, you'll have to keep another field around which carries the sequential number of the line in the order. By combining this number with OrderNum, you have another candidate key, and you're back to the start.

Heinz

rs wrote:
>
> I know that (OrderNum, LineNum) should semantically be the PK.
>
> What if the following were done :
>
> set OrderLineID as the PK for the ORDERLINE table, and have OrderNum as
> a FK.
>
> By doing that, am I helping myself in terms of efficiency with indexing in
> any way or
> is there no real benefit from doing that?
>
> If I wanted to go forward with the approach I described, how would I set up
> a unique
> sequence in Oracle in order to accomplish this ?
>
> Raju
>
> "Jan Lenders" <J.Lenders_at_Betuwe.net> wrote in message
> news:8sfc8l$ncm$1_at_nnrp1.deja.com...
> > Okay, but what about an ORDERLINE table, which is dependent on a ORDER
> > table.
> > ORDER (PK OrderNum)
> > ORDERLINE (PK OrderNum, LineNum)
> > LineNum is unique per OrderNum and does not have to be unique within
> > the ORDERLINE table.
> >
> > Your turn...
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
Received on Tue Oct 17 2000 - 08:15:14 CEST

Original text of this message