Re: doubt

From: Richard Huxton <dev(at)archonet(dot)com>
To: sathish <sathish(at)ceedees(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: doubt
Date: 2004-06-14 17:51:42
Message-ID: 40CDE5AE.30405@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

sathish wrote:
> dear groups,
> i have a doubt in sql,
> i have a table staff_skills in which i have set a table level
> constraint to create a primary key of two fields .
> so 'name' and 'skill' combinedly forms a primary key.
> now the issue is in another table i have only 'name' field and i want
> to create a foreign key constraint which refers the staff_skills table's
> 'name' field only.
> staff_skills (table) - name,skill,ability (columns) --- primary
> key(name,skill)
> staff_xxxx (table) - name,x,y,z (columns) --- foreign
> key(name) references staff_skills(name).
> how to do the above?

You can't. If any occurrence of e.g. "John" in staff_skills refers to
the same person then you should have a separate "person" table to hold
their details.

Your staff_xxx tables can then reference table "person".

--
Richard Huxton
Archonet Ltd

In response to

  • doubt at 2004-06-11 09:42:36 from sathish

Responses

  • Re: doubt at 2004-06-14 20:23:15 from Laura Vance

Browse pgsql-general by date

  From Date Subject
Next Message Duane Lee - EGOVX 2004-06-14 17:51:58 Re: Keep history of modifications
Previous Message Scot L. Harris 2004-06-14 17:19:30 Re: Installing 7.4.2