Re: foreing key .. reference..

From: Andrew McMillan <andrew(at)catalyst(dot)net(dot)nz>
To: Andres Ledesma <aledes(at)telefonica(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: foreing key .. reference..
Date: 2003-02-22 08:23:30
Message-ID: 1045902210.4043.2666.camel@kant.mcmillan.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Sat, 2003-02-22 at 12:13, Andres Ledesma wrote:
> Hi evbody...
>
> Could anybody give me an example of foreing key ..references example ?

Here is an example from one of our applications.

Regards,
Andrew.

---------------------------
-- Contact Details
---------------------------
CREATE TABLE contact (
contact_id INT4,
name TEXT,
address1 TEXT,
address2 TEXT,
city TEXT,
state TEXT,
country TEXT,
postcode TEXT,
phone TEXT, -- format is "+<contrycode>
(<areacode>) <localnumber>"
fax TEXT, -- format is "+<contrycode>
(<areacode>) <localnumber>"
email TEXT,
PRIMARY KEY ( contact_id )
);

---------------------------
-- Registrar Details
---------------------------
CREATE TABLE registrar (
registrar_id INT4,
p_contactid INT4,
d_contactid INT4,
s_contactid INT4,
registrar_name TEXT,
commenced TIMESTAMP,
PRIMARY KEY ( registrar_id ),
CONSTRAINT p_contact_of_contact FOREIGN KEY ( p_contactid ) REFERENCES
contact,
CONSTRAINT d_contact_of_contact FOREIGN KEY ( d_contactid ) REFERENCES
contact,
CONSTRAINT s_contact_of_contact FOREIGN KEY ( s_contactid ) REFERENCES
contact
);

--
---------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267
Survey for nothing with http://survey.net.nz/
---------------------------------------------------------------------

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Andres Ledesma 2003-02-22 10:18:41 Re: foreing key .. reference..thanks a lot ...
Previous Message Andres Ledesma 2003-02-21 23:13:54 foreing key .. reference..