Relationships

Поиск
Список
Период
Сортировка
Искать

Relationships

От:
"Mike Hammonds" <mhammonds@knowledgeinenergy.com>
Дата:
Вложения:
** Reply Requested When Convenient **

How do I create relationships in PgSQL or in PgAdmin?

Mike Hammonds, CNE5, MCP-NT
Fellon-McCord & Associates, Inc. 
Office:  502.214-6324
Fax:      502.426.8800
mhammonds@knowledgeinenergy.com
Show Me the Code!!
ICQ#94969305

Re: Relationships

От:
Joel Burton <jburton@scw.org>
Дата:
> 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   
Director of Information Systems, Support Center of Washington

FAQ