From: Janning Vygen <vygen@planwerk6.de>
To: pgsql-sql@postgresql.org
Subject: Problem with n to n relation
Date: Fri, 5 Oct 2001 12:39:40 +0200
Message-ID: <0110051239400B.30993@janning> (raw)
Hi,
i create n to n relations like this, right?
create table person (
id serial,
name text
);
create table address (
id serial,
street text
...
);
create table person2adress (
id serial,
person_id integer not null references person(id),
address_id integer not null references address(id),
);
than i can select all adresses from one person with id =1 with
select street
from address
where id =
(
select adress_id
from person2adress
where person_id = 1
);
ok so far so good. but you can still insert persons without any
adress. so its a 0..n relation. But how van i achieve that you can“t
insert any person without adress???
thanks in advance
janning
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: vygen@planwerk6.de
Subject: Re: Problem with n to n relation
In-Reply-To: <0110051239400B.30993@janning>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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