Re: Relationships

From: Joel Burton <jburton(at)scw(dot)org>
To: Mike Hammonds <mhammonds(at)knowledgeinenergy(dot)com>
Cc: pgadmin-support(at)greatbridge(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Re: Relationships
Date: 2001-01-11 16:35:42
Message-ID: Pine.LNX.4.21.0101111132540.14673-100000@olympus.scw.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> How do I create relationships in PgSQL or in PgAdmin?

Same way in most SQL-based databases: through the DDL statements such as
CREATE TABLE or ALTER TABLE.

For example

CREATE TABLE PARENT (ID INT PRIMARY KEY, LNAME TEXT);
CREATE TABLE CHILD (PID INT REFERENCES PARENT, LNAME TEXT);

will "create a relationship" between the parent and child tables.
(If you're coming from a background in Access or something similar,
this creates a relationship
with "referential integrity" but without any cascades--PG supports
cascading; see CREATE TABLE man for details)

--
Joel Burton <jburton(at)scw(dot)org>
Director of Information Systems, Support Center of Washington

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Rosa Maria Carro Salas 2001-01-11 17:11:20 RecordSets, getString and charSets
Previous Message Mike Hammonds 2001-01-11 16:27:59 Relationships