Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Question on Primary Keys
Well, the OrderLine field will always exist no matter what. What I am asking about is the potential benefits of creating a new unique column called OrderLineID so that there is only a single column PK. The question is : Is there any benefit ?? (or downside)
"Heinz Huber" <Heinz.Huber_at_elbanet.co.at> wrote in message
news: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 - 01:41:46 CDT
![]() |
![]() |