| From: | Jaime Casanova <systemguards(at)gmail(dot)com> |
|---|---|
| To: | Gianluca Riccardi <ml-reader(at)moonwatcher(dot)it> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: DB design and foreign keys |
| Date: | 2005-12-13 18:32:58 |
| Message-ID: | c2d9e70e0512131032h6591086dwfc73ef57a9c2503b@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
[...unnecesary...]
> CREATE TABLE orders (
> id serial,
> order_code serial,
> customer_code integer REFERENCES customers (customer_code) NOT NULL,
> order_date time without time zone NOT NULL,
> remote_ip inet NOT NULL,
> order_time timestamp with time zone NOT NULL,
> order_type varchar(10) NOT NULL,
> state varchar(10) NOT NULL,
> PRIMARY KEY (id, order_code)
^^^^^^^^^^^^^^^^^^^
> );
[...unnecesary...]
>
> CREATE TABLE order_items (
> id serial,
> order_code integer REFERENCES orders (order_code) NOT NULL,
^^^^^^^^^^^^^^
[...unnecesary...]
> ERROR: there is no unique constraint matching given keys for referenced
> table "orders"
this is because the PK in the orders table has two fields not one...
so it founds no unique index on orders(order_code)
--
Atentamente,
Jaime Casanova
(DBA: DataBase Aniquilator ;)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Huxton | 2005-12-13 18:59:47 | Re: DB design and foreign keys |
| Previous Message | Tom Lane | 2005-12-13 18:31:29 | Re: DB design and foreign keys |