Re: table referencing several others

From: PFC <lists(at)peufeu(dot)com>
To: "Louis-David Mitterrand" <vindex+lists-pgsql-general(at)apartia(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: table referencing several others
Date: 2007-05-28 12:40:16
Message-ID: op.ts1etec1cigqcu@apollo13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Here what I would do :

- Have a table "objects", which contains locations, shows, persons, well
anything you want to relate to the forums in question.
- Simply add an object_id to your forums table.

Now, how do you distinguish between different types of objects in your
objects table ?
You can add an object_type field and teach your object-relational mapper
that it expresses the class of object that should be instantiated when
fetching the rows.
You can have fields that are only used by some types of objects, and null
for others.
You can use table inheritance.
You can also have an objects table, and tables locations_extra_infos,
people_extra_info which store the fields that are unique to each type of
object.

> - every subsequent message of the thread will carry these useless fields
> (only the first message in thread uses one of them),

If the fields are set to NULL, they will only use one bit, so this is not
a problem.
Do not store the location_id in each message of the thread : if you want
to change it, you'll have to update all the messages !

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2007-05-28 12:52:24 Re: createdb.exe prompting for password on Vista
Previous Message mkwong8888 2007-05-28 11:14:10 Re: Geographic data sources, queries and questions