pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: ASAKALAL@bouyguestelecom.fr
Cc: pgsql-sql@postgresql.org
Subject: Re: RE : Foreign key
Date: Wed, 30 Mar 2005 09:31:38 -0700
Message-ID: <20050330163138.GA35656@winnie.fuhr.org> (raw)
In-Reply-To: <DB7F9CBEADC6D4118F5600508B442F0308611FA9@bt1sqtbe.bpa.bouyguestelecom.fr>
References: <DB7F9CBEADC6D4118F5600508B442F0308611FA9@bt1sqtbe.bpa.bouyguestelecom.fr>

On Wed, Mar 30, 2005 at 02:09:05PM +0200, ASAKALAL@bouyguestelecom.fr wrote:
> 
> Thanks for your answers but i make the modifications, the same error returned.
> Here my script :
> ...
> Create table Salariés (Nom_salarié VARCHAR(20), 
>                                    Prénom VARCHAR(20),
> Fonction VARCHAR(50),
> Service VARCHAR(50),
> Adresse VARCHAR(100),
> Numero_SS integer,
> Matricule VARCHAR(6),
> rs_ssii VARCHAR(30) references ssii,
> PRIMARY KEY ( Nom_salarié, rs_ssii)) ;

The salariés table has a primary key with two columns.

> Create table Compteur (id integer, 
>                                    Heures_travaillées decimal(6,2),
> Cp_acquis decimal(6,2),
> Cp_pris decimal(6,2),
> RTT_acquis decimal(6,2),
> RTT_pris decimal(6,2),
> Nom_salarié VARCHAR(20) references salariés,
> rs_ssii VARCHAR(30) references ssii,
> PRIMARY KEY ( Nom_salarié,rs_ssii,Id)) ;

The foreign key reference to salariés has only one column but
the primary key for salariés has two columns, hence the error.
It looks like you should be doing this:

Nom_salarié VARCHAR(20),
rs_ssii VARCHAR(30),
FOREIGN KEY (Nom_salarié, rs_ssii) REFERENCES salariés,

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



view thread (2+ messages)  latest in thread

Message-ID: <20050330163138.GA35656@winnie.fuhr.org>
Permalink:  ../20050330163138.GA35656@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20050330163138.GA35656@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mike@fuhr.org, ASAKALAL@bouyguestelecom.fr
  Subject: Re: RE : Foreign key
  In-Reply-To: <20050330163138.GA35656@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox