table referencing several others

Поиск
Список
Период
Сортировка
От Louis-David Mitterrand
Тема table referencing several others
Дата
Msg-id 20070528092600.GA8134@apartia.fr
обсуждение исходный текст
Ответы Re: table referencing several others  (PFC <lists@peufeu.com>)
Список pgsql-general
Hello,

To support a forum application I have a "forum" table:

   Column    |            Type
-------------+-----------------------------
 created_by  | integer
 created_on  | timestamp without time zone
 modified_by | integer
 modified_on | timestamp without time zone
 id_forum    | integer
 id_parent   | integer
 subject     | text
 message     | text
 id_show     | integer
 id_thread   | integer
 id_person   | integer


The id_show and id_person columns are meant to point to a show or person
object about which the specific forum thread is started (threads can
also have a "free" subject and these fields are then empty).

Now I'd like to add forums about locations (theatres, museums, etc.) so
I am thinking about adding an id_location column, but this method seems
a bit inelegant to me:

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

- if I want to connect a forum to a new type of object, yet a new
  id_<object> will be required,

Is there a better way to have a single field that can relate with
several objects and still benefit from integrity checks?

Thanks,

В списке pgsql-general по дате отправления:

Предыдущее
От: "Chuck D."
Дата:
Сообщение: Re: Geographic data sources, queries and questions
Следующее
От: Teodor Sigaev
Дата:
Сообщение: Re: crash creating tsearch2 index