Re: many-to-many relationship - Mailing list pgsql-sql

From Louis-David Mitterrand
Subject Re: many-to-many relationship
Date
Msg-id 20081006152532.GA29877@apartia.fr
Whole thread Raw
In response to Re: many-to-many relationship  (Dave Steinberg <dave-pgsql@redterror.net>)
List pgsql-sql
On Mon, Oct 06, 2008 at 09:25:09AM -0400, Dan McFadyen wrote:
> Hello,
> 
> Simplest way I can think of is create 3 relation tables, a person/image
> table, location/image table and event/image table.
> 
> Each is just made up for 2 foreign keys to the first ID and image ID,
> using both as the PK for the table.

On Mon, Oct 06, 2008 at 09:30:41AM -0400, Dave Steinberg wrote:
> The typical way to do this would be to have your image table be just  
> about images, and then to isolate the relationship information into  
> mapping tables.  Those would look like:
>
> image <=> people
> (image_id, person_id), with the primary key being the pair of columns.  
> In SQL, roughly:

Thanks Dan and Dave,

you suggested the same solution which seems the most reasonable.

-- 
http://www.lesculturelles.net


pgsql-sql by date:

Previous
From: Dave Steinberg
Date:
Subject: Re: many-to-many relationship
Next
From: Emi Lu
Date:
Subject: pg_dump more than one table in one command?