Received: from issv0171.isis.de (issv0171.isis.de [195.158.131.223]) by postgresql.org (8.11.3/8.11.4) with SMTP id f988Vjn92213 for ; Mon, 8 Oct 2001 04:31:46 -0400 (EDT) (envelope-from vygen@planwerk6.de) Received: (qmail 10663 invoked by uid 1010); 8 Oct 2001 08:31:42 -0000 Received: from unknown (HELO janning.planwerk6.local) ([195.158.137.68]) (envelope-sender ) by 0 (qmail-ldap-1.03) with SMTP for ; 8 Oct 2001 08:31:42 -0000 Received: from janning (localhost [127.0.0.1]) by janning.planwerk6.local (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) with SMTP id f988U1Y05699 for ; Mon, 8 Oct 2001 10:30:01 +0200 From: Janning Vygen Organization: Planwerk 6 /websolutions To: pgsql-sql@postgresql.org Subject: Re: Problem with n to n relation Date: Mon, 8 Oct 2001 10:30:01 +0200 X-Mailer: KMail [version 1.1.99] Content-Type: text/plain; charset="iso-8859-1" References: <5.0.2.1.0.20011005082745.0273b430@mail.e4media.com> In-Reply-To: <5.0.2.1.0.20011005082745.0273b430@mail.e4media.com> MIME-Version: 1.0 Message-Id: <0110081030010H.05461@janning> Content-Transfer-Encoding: 8bit X-Archive-Number: 200110/107 X-Sequence-Number: 5062 Am Freitag, 5. Oktober 2001 14:30 schrieb Morgan Curley: > just get rid of the serial_id in person2adress -- there is no > reason for it. Make the pk of that table a composite --> person_id, > address_id <-- that way you have added some additional integrity to > your structure. Only one record can exist ffor a given person at a > given address. However any person can have any number of address > and any address can have any number of people living at it. ok fine, i understood it after i figured out what pk means :-) but how do i reach my goal. It should not be allowed to have a person without any address?? janning > At 12:39 PM 10/5/2001 +0200, Janning Vygen wrote: > >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???