Re: DB design and foreign keys - Mailing list pgsql-sql

From Gianluca Riccardi
Subject Re: DB design and foreign keys
Date
Msg-id 439FF2E9.5040405@moonwatcher.it
Whole thread Raw
In response to Re: DB design and foreign keys  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
[cut]

> order_code is not by itself unique --- SERIAL doesn't guarantee that.
>  
>
that was my misunderstanding, i thought (misunderstood) that 'serial' 
implied 'unique'

> I'm not sure why you are declaring the primary key of orders as being
> the combination of *two* serial columns,

i thought it was good design choice and even needed for foreign keys 
referencing on them

> but if that's what you really
> need
>
i'm not shure about that

> and you also want to be able to reference a row by just one of
> them, you'll need to apply a separate unique constraint to just the
> order_code column.
>  
>
sorry, i'm afraid i didn't understand: are you suggesting to apply the 
constraint in case the primary key is kept on the combination of the two 
serial columns? or to remove the primary key of the two serial columns?

>             regards, tom lane
>  
>
thanks a lot for your kind response, best regards,
Gianluca Riccardi


pgsql-sql by date:

Previous
From: "Magnus Hagander"
Date:
Subject: Re: Multi-row update w. plpgsql function
Next
From: Gianluca Riccardi
Date:
Subject: Re: DB design and foreign keys