pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedprimary + foreign key
7+ messages / 4 participants
[nested] [flat]
* primary + foreign key
@ 2002-12-12 08:29 Huub <v.niekerk@freeler.nl>
0 siblings, 1 reply; 7+ messages in thread
From: Huub @ 2002-12-12 08:29 UTC (permalink / raw)
To: pgsql-sql
Hi,
I want to create a table where the 2 columns are both primary as well as
foreign key. What is the correct syntax for that?
Thanks
Huub
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: primary + foreign key
@ 2002-12-12 08:54 Tomasz Myrta <jasiek@klaster.net>
parent: Huub <v.niekerk@freeler.nl>
0 siblings, 1 reply; 7+ messages in thread
From: Tomasz Myrta @ 2002-12-12 08:54 UTC (permalink / raw)
To: Huub <v.niekerk@freeler.nl>; +Cc: pgsql-sql
Huub wrote:
> Hi,
>
> I want to create a table where the 2 columns are both primary as well as
> foreign key. What is the correct syntax for that?
>
> Thanks
>
> Huub
create table detail
(
id1 integer,
id2 integer,
CONSTRAINT c1 PRIMARY KEY(id1,id2),
CONSTRAINT c2 FOREIGN KEY(id1,id2) REFERENCES master
);
Do you really need such detail table? You can just add columns to master
table.
Tomasz Myrta
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: primary + foreign key
@ 2002-12-12 09:02 Huub <v.niekerk@freeler.nl>
parent: Tomasz Myrta <jasiek@klaster.net>
0 siblings, 1 reply; 7+ messages in thread
From: Huub @ 2002-12-12 09:02 UTC (permalink / raw)
To: pgsql-sql
Hi,
I suppose 'detail' is the table name? And what is master?
Thanks
Huub
> create table detail
> (
> id1 integer,
> id2 integer,
> CONSTRAINT c1 PRIMARY KEY(id1,id2),
> CONSTRAINT c2 FOREIGN KEY(id1,id2) REFERENCES master
> );
>
> Do you really need such detail table? You can just add columns to master
> table.
>
> Tomasz Myrta
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: primary + foreign key
@ 2002-12-12 09:52 Tomasz Myrta <jasiek@klaster.net>
parent: Huub <v.niekerk@freeler.nl>
0 siblings, 1 reply; 7+ messages in thread
From: Tomasz Myrta @ 2002-12-12 09:52 UTC (permalink / raw)
To: Huub <v.niekerk@freeler.nl>; +Cc: pgsql-sql
Huub wrote:
> Hi,
>
> I suppose 'detail' is the table name? And what is master?
>
> Thanks
>
> Huub
You should know that.
Detail is a table you want to create and master is a table where foreign
key points to.
Tomasz Myrta
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: primary + foreign key
@ 2002-12-12 09:54 Huub <v.niekerk@freeler.nl>
parent: Tomasz Myrta <jasiek@klaster.net>
0 siblings, 1 reply; 7+ messages in thread
From: Huub @ 2002-12-12 09:54 UTC (permalink / raw)
To: pgsql-sql
Thanks for pointing out. I'm not that experienced in SQL yet; so detail
could as well be some extra instruction and I've never seen 'references
master' before. But I think I'll manage now. Thanks
Tomasz Myrta wrote:
> Huub wrote:
>
>
>>Hi,
>>
>>I suppose 'detail' is the table name? And what is master?
>>
>>Thanks
>>
>>Huub
>
>
> You should know that.
> Detail is a table you want to create and master is a table where foreign
> key points to.
>
> Tomasz Myrta
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: primary + foreign key
@ 2002-12-12 16:27 Roberto Mello <rmello@cc.usu.edu>
parent: Huub <v.niekerk@freeler.nl>
0 siblings, 1 reply; 7+ messages in thread
From: Roberto Mello @ 2002-12-12 16:27 UTC (permalink / raw)
To: Huub <v.niekerk@freeler.nl>; +Cc: pgsql-sql
On Thu, Dec 12, 2002 at 10:54:21AM +0100, Huub wrote:
> Thanks for pointing out. I'm not that experienced in SQL yet; so detail
> could as well be some extra instruction and I've never seen 'references
> master' before. But I think I'll manage now. Thanks
Read "An Introduction to Database Systems" by C.J. Date.
-Roberto
--
+----| Roberto Mello - http://www.brasileiro.net/ |------+
+ Computer Science Graduate Student, Utah State University +
+ USU Free Software & GNU/Linux Club - http://fslc.usu.edu/ +
Wasn't dat special?
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: primary + foreign key
@ 2002-12-12 18:22 Bret Hughes <bhughes@elevating.com>
parent: Roberto Mello <rmello@cc.usu.edu>
0 siblings, 0 replies; 7+ messages in thread
From: Bret Hughes @ 2002-12-12 18:22 UTC (permalink / raw)
To: pgsql-sql
On Thu, 2002-12-12 at 10:27, Roberto Mello wrote:
>
> Read "An Introduction to Database Systems" by C.J. Date.
>
Boy that brings back memories. I think I will dig it out of a box since
I am doing database coding again after a long hiatus. Seems like I had
a couple of Date books on my shelf at on time.
After lurking several pgsql lists for a while now I see why the db2 dbas
used to get so bent out of shape with boneheaded queries. Especially
since each project got billed for MVS CPU time :)
Bret
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2002-12-12 18:22 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-12-12 08:29 primary + foreign key Huub <v.niekerk@freeler.nl>
2002-12-12 08:54 ` Tomasz Myrta <jasiek@klaster.net>
2002-12-12 09:02 ` Huub <v.niekerk@freeler.nl>
2002-12-12 09:52 ` Tomasz Myrta <jasiek@klaster.net>
2002-12-12 09:54 ` Huub <v.niekerk@freeler.nl>
2002-12-12 16:27 ` Roberto Mello <rmello@cc.usu.edu>
2002-12-12 18:22 ` Bret Hughes <bhughes@elevating.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