Indirect access to data, given table name as a string

Поиск
Список
Период
Сортировка
От Arthaey Angosii
Тема Indirect access to data, given table name as a string
Дата
Msg-id 1177205517.700237.208910@y80g2000hsf.googlegroups.com
обсуждение исходный текст
Ответы Re: Indirect access to data, given table name as a string
Re: Indirect access to data, given table name as a string
Список pgsql-general
I want to allow "notes" on any row in any table in my database. A
table row may have multiple notes. Say my tables are "foo," "bar," and
"qux." I want to avoid having a lookup table for each of them
("foo_notes," "bar_notes," and "qux_notes").

Is there a standard way of solving this problem?

Not knowing SQL all that well, I thought that maybe I could have a
"notes" table:

CREATE TABLE notes (
    id integer primary key,
    table_name regclass not null,
    row_id integer not null,
    note text not null
);

But I have no idea how I could use notes.table_name and notes.row_id
to relate (table_name.id = row_id) to notes.note. I've looked a little
bit at information_schema and the system catalog, but I haven't found
any examples of what I'm trying to do, so I don't know if I'm on the
right track here.

Any suggestions would be appreciated!


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

Предыдущее
От: judexhuang@gmail.com
Дата:
Сообщение: can't start tsearch2 in 8.2.4
Следующее
От: judexhuang@gmail.com
Дата:
Сообщение: Re: can't start tsearch2 in 8.2.4