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

From Gianluca Riccardi
Subject Re: DB design and foreign keys
Date
Msg-id 439FF36F.1040004@moonwatcher.it
Whole thread Raw
In response to Re: DB design and foreign keys  (Richard Huxton <dev@archonet.com>)
List pgsql-sql
[cut]

>
> It means what it says. You have defined table orders with a primary 
> key of (id,order_code). This means that the combination of 
> (id,order_code) must be unique. 


yes, that was my thought, and in that context, i thought it could be 
correct in order to have uniqueness for creating foreign keys

> So - these could all exist at the same time:
>  (1,1), (1,2), (2,1), (2,2)
> You could not then add another (1,2) combination.


yes, again, i thought that was the uniqueness i needed...

>
> Since id and order_code are both just automatically-generated numbers 
> in the orders table it doesn't add anything to make both of them part 
> of a primary-key. I would delete the id column altogether and just 
> have the order_code as the primary-key (since "order_code" carries 
> more meaning to a human than "id"). This means your order_items table 
> can then safely reference the order_code it wants to.



> HTH


sure it did, thanks for your response, best regards,
Gianluca Riccardi


pgsql-sql by date:

Previous
From: Gianluca Riccardi
Date:
Subject: Re: DB design and foreign keys
Next
From: Gianluca Riccardi
Date:
Subject: Re: DB design and foreign keys