From: | Kevin Hunter <hunteke(at)earlham(dot)edu> |
---|---|
To: | Postgres General List <pgsql-general(at)postgresql(dot)org> |
Cc: | Caktus Team <team(at)caktusgroup(dot)com> |
Subject: | Re: many to one of many modeling question |
Date: | 2008-01-07 19:32:26 |
Message-ID: | 47827E4A.2030309@earlham.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Hannes Dorbath | 2008-01-07 19:46:01 | Re: Index trouble with 8.3b4 |
Previous Message | Greg Smith | 2008-01-07 19:27:40 | Re: calculating shared data memory space |