X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 2D2879DC82E for ; Fri, 24 Mar 2006 15:34:45 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23213-02 for ; Fri, 24 Mar 2006 15:34:44 -0400 (AST) X-Greylist: delayed 00:59:59.838529 by SQLgrey- Received: from vms040pub.verizon.net (vms040pub.verizon.net [206.46.252.40]) by postgresql.org (Postfix) with ESMTP id 85A2A9DC813 for ; Fri, 24 Mar 2006 15:34:40 -0400 (AST) Received: from [127.0.0.1] ([71.101.76.239]) by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPA id <0IWN002F9A9OOFT1@vms040.mailsrvcs.net> for pgsql-sql@postgresql.org; Fri, 24 Mar 2006 12:34:42 -0600 (CST) Date: Fri, 24 Mar 2006 13:34:34 -0500 From: Joe Subject: Re: Question about One to Many relationships In-reply-to: <226d83de0603240937o7b5608f9je5179238ee3c9c5a@mail.gmail.com> To: Todd Kennedy Cc: "D'Arcy J.M. Cain" , pgsql-sql@postgresql.org Message-id: <44243BBA.8030802@freedomcircle.net> Organization: Freedom Circle, LLC MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit References: <226d83de0603240852q54af3512odfce218d69718c8b@mail.gmail.com> <20060324120142.d3fdf477.darcy@druid.net> <226d83de0603240937o7b5608f9je5179238ee3c9c5a@mail.gmail.com> User-Agent: Thunderbird 1.5 (Windows/20051201) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] X-Spam-Score: 0.08 X-Spam-Level: X-Archive-Number: 200603/386 X-Sequence-Number: 24732 Todd Kennedy wrote: > They haven't responded me as of yet. There should be a band associated > with each album -- this is handled in code, but other than that this > is the only relational db way I can think of to do it. But if a band can have songs in many albums and an album can have songs from multiple bands, it's a many-to-many relationship, NOT one-to-many. Short of the full track design suggested by PFC, you'd normally implement a many-to-many table as follows: CREATE TABLE bands_on_album ( band_id integer REFERENCES band (id), album_id integer REFERENCES albums (id), PRIMARY KEY (band_id, album_id) ) This of course precludes the same band being listed twice in a given album. If you do need that info, then you're really asking for "tracks". Joe