Search Postgresql Archives

Re: many to one of many modeling question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux