Re: DB design and foreign keys

Поиск
Список
Период
Сортировка
От Gianluca Riccardi
Тема Re: DB design and foreign keys
Дата
Msg-id 439FF36F.1040004@moonwatcher.it
обсуждение исходный текст
Ответ на Re: DB design and foreign keys  (Richard Huxton <dev@archonet.com>)
Список 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 по дате отправления:

Предыдущее
От: Gianluca Riccardi
Дата:
Сообщение: Re: DB design and foreign keys
Следующее
От: Gianluca Riccardi
Дата:
Сообщение: Re: DB design and foreign keys