Re: DB design and foreign keys

From: Gianluca Riccardi <ml-reader(at)moonwatcher(dot)it>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: DB design and foreign keys
Date: 2005-12-14 10:26:55
Message-ID: 439FF36F.1040004@moonwatcher.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Gianluca Riccardi 2005-12-14 10:27:47 Re: DB design and foreign keys
Previous Message Gianluca Riccardi 2005-12-14 10:25:50 Re: DB design and foreign keys