Re: problem with uniques and foreing keys - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: problem with uniques and foreing keys
Date
Msg-id 20060506115248.G47923@megazone.bigpanda.com
Whole thread Raw
In response to problem with uniques and foreing keys  ("kernel.alert kernel.alert" <kernel.alert@gmail.com>)
List pgsql-sql
On Sat, 6 May 2006, kernel.alert kernel.alert wrote:

> I create the follow tables...
>
> --------------------------------------------------------
>
> CREATE TABLE empresa (
>   id_empresa         integer  NOT NULL primary key,
>   nombre             varchar(45),
> );
> CREATE TABLE casino (
>   id_casino          integer  NOT NULL,
>   id_empresa         integer      REFERENCES empresa(id_empresa),
>
>   nombre             varchar(45),
>
>   primary key(id_casino,id_empresa)
> );
> CREATE TABLE maq_casino (
>   id_empresa      integer  NOT NULL REFERENCES  casino(id_empresa),
>   id_casino       integer  NOT NULL REFERENCES  casino(id_casino),

You probably want a table level constraint like:

foreign key (id_casino, id_empresa) references casino(id_casino,
id_empresa)

That's not the same as two single-column constraints which is what you
have above.


pgsql-sql by date:

Previous
From: "kernel.alert kernel.alert"
Date:
Subject: Re: problem with uniques and foreing keys
Next
From: Bryce Nesbitt
Date:
Subject: Re: grant select on database demo to user