pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedPrimary and foreign key
3+ messages / 3 participants
[nested] [flat]
* Primary and foreign key
@ 1998-09-15 21:24 Daniel Facciolo Pires <dfpires@pilsen.intermidia.icmsc.sc.usp.br>
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Facciolo Pires @ 1998-09-15 21:24 UTC (permalink / raw)
To: pgsql-sql
I don't know how can I set an attribute like a primary key.
And how can I set the references integrated.
I saw at help's PostgreSQL:
create table <class_name>
(<attr1> <type1> [default <expression>] [not null] [,...])
[inherits (<class_name1>,...<class_nameN>)
[[constraint <name>] check <condition> [,...] ]
Will I have to control the integrated by myself in the program?
Thanks!
-----------------------------------------
Daniel Facciolo Pires
Mestrado em Ciencias da Computacao
ICMC-USP-Sao Carlos
Grupo: Hipermidia
dfpires@intermidia.icmc.sc.usp.br
http://www.intermidia.icmc.sc.usp.br/~dfpires
^ permalink raw reply [nested|flat] 3+ messages in thread
* Primary and Foreign Key?
@ 2005-09-23 01:13 Announce <truthhurts@insightbb.com>
2005-09-23 01:34 ` Re: Primary and Foreign Key? Russell Simpkins <russellsimpkins@hotmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Announce @ 2005-09-23 01:13 UTC (permalink / raw)
To: pgsql-sql
I have the following related tables:
PEOPLE
--------------
peopleid pkey,
name,
etc
GROUPS
-------------
groupid pkey,
description,
etc
PEOPLEGROUPS
-------------------
peopleid pkey/fkey,
groupid pkey/fkey
What is the CORRECT way (in Postgres) to define the PEOPLEGROUPS table so
that it has both the double primary key AND still acts as a foreign key for
people.peopleid and groups.groupid? Can i specify both or is this not
necessary? Any suggestions would be appreciated.
Thanks!
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.4/109 - Release Date: 9/21/2005
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Primary and Foreign Key?
2005-09-23 01:13 Primary and Foreign Key? Announce <truthhurts@insightbb.com>
@ 2005-09-23 01:34 ` Russell Simpkins <russellsimpkins@hotmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Russell Simpkins @ 2005-09-23 01:34 UTC (permalink / raw)
To: truthhurts@insightbb.com; pgsql-sql
This is valid ddl to accomplish what you wish.
create table peoplegroups {
peopleid int not null,
groupid int not null,
primary key (peopleid, groupid),
foreign key (peopleid) references people,
foreign key (groupid) references group
}
Check the docs for other options etc.
>From: "Announce" <truthhurts@insightbb.com>
>To: "PostgreSQL SQL List" <pgsql-sql@postgresql.org>
>Subject: [SQL] Primary and Foreign Key?
>Date: Thu, 22 Sep 2005 20:13:35 -0500
>
>I have the following related tables:
>
>PEOPLE
>--------------
>peopleid pkey,
>name,
>etc
>
>
>GROUPS
>-------------
>groupid pkey,
>description,
>etc
>
>
>PEOPLEGROUPS
>-------------------
>peopleid pkey/fkey,
>groupid pkey/fkey
>
>
>What is the CORRECT way (in Postgres) to define the PEOPLEGROUPS table so
>that it has both the double primary key AND still acts as a foreign key for
>people.peopleid and groups.groupid? Can i specify both or is this not
>necessary? Any suggestions would be appreciated.
>
>Thanks!
>
>--
>No virus found in this outgoing message.
>Checked by AVG Anti-Virus.
>Version: 7.0.344 / Virus Database: 267.11.4/109 - Release Date: 9/21/2005
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-09-23 01:34 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-09-15 21:24 Primary and foreign key Daniel Facciolo Pires <dfpires@pilsen.intermidia.icmsc.sc.usp.br>
2005-09-23 01:13 Primary and Foreign Key? Announce <truthhurts@insightbb.com>
2005-09-23 01:34 ` Re: Primary and Foreign Key? Russell Simpkins <russellsimpkins@hotmail.com>
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