At 2:09p -0500 on 07 Jan 2008, brian wrote:
Kevin Hunter wrote:
Is there a clever/clean way of having the comments foreign key into
the multiple tables?
If, by object, you mean that you have several tables, each row of which
should be associated with one or more comments, the best way would be to
create join tables for each of those tables:
:-( Yeah this is one method. I was hoping for something cleaner though.
Something along the lines of
CREATE TABLE o_1 ( id SERIAL ... );
CREATE TABLE o_2 ( id SERIAL ... );
CREATE TABLE o_3 ( id SERIAL ... );
CREATE TABLE comments (
id SERIAL,
obj_id INTEGER ...
FOREIGN KEY (obj_id) REFERENCES ONE OF o_1(id), o_2(id), o_3(id)
);
This obviously won't syntactically work, but you perhaps get the drift ...
Out of curiosity, is this for a CakePHP app?
Nope. This is for a customers private project. Sorry! :-)
Kevin
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org/