many-to-many relationship

From: Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: many-to-many relationship
Date: 2008-10-06 13:08:02
Message-ID: 20081006130802.GA23018@apartia.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

Say you have several objects (tables): person, location, event, etc. all
of which can have several images attached.

What is the best way to manage relations between a single 'image' table
and these different objects?

For now each 'image' row has pointers to id_person, id_location,
id_event, etc. (only one of which is used for any given row).

Is there a better way, more elegant way to do it, without using
redundant id_* pointers on each row and yet still enforce foreign keys?

Thanks,

--
http://www.lesculturelles.net

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Dave Steinberg 2008-10-06 13:30:41 Re: many-to-many relationship
Previous Message Marc Mamin 2008-10-03 20:29:12 Re: Query how-to