Search Postgresql Archives

Re: Polymorphic delete help needed

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

 



On Thu, Jul 05, 2007 at 09:56:12PM -0500, Perry Smith wrote:
> I am doing a project using Ruby On Rails with PostgreSQL as the  
> database.  I have not seen the term polymorphic used with databases  
> except with Rails so I will quickly describe it.

You have now :)

http://archives.postgresql.org/sfpug/2005-04/msg00022.php

> Instead of holding just an id as a foreign key, the record holds a  
> "type" field which is a string and an id.  The string is the name of  
> the table to which the id applies.  (That is slightly simplified).

This is brittle by nature.  The above link sketches out a way to make
it stable.  If you have questions, ask :)

> The first problem

of many ;)

[other stuff snipped]

> that creates is it makes it hard to do a constraint  
> on the name/id pair.

Let PostgreSQL work *for* you instead of picking a fight with it and
then piling on heaps of unnecessary code.

Cheers,
David.
-- 
David Fetter <david@xxxxxxxxxx> http://fetter.org/
phone: +1 415 235 3778        AIM: dfetter666
                              Skype: davidfetter

Remember to vote!
Consider donating to PostgreSQL: http://www.postgresql.org/about/donate



[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