On Fri, Jul 06, 2007 at 08:39:50AM -0500, Perry Smith wrote: > > On Jul 6, 2007, at 8:01 AM, David Fetter wrote: > > >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. > > I really want to follow this particular edict. Rails makes it easy > to put the checking up in Rails but, I assume that if the interface > between PostgreSQL and one of its languages like "SQL" or Python, > etc is an inch thick, then the interface between Rails and > PostgreSQL would be 12 inches thick. At some point, you're going to realize that Rails is the problem, not the solution. It's written by people who do not understand what a shared data store is and reflects problems inherent in its native database platform: MySQL 3.23. 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