Re: Polymorphic delete help needed
От | Perry Smith |
---|---|
Тема | Re: Polymorphic delete help needed |
Дата | |
Msg-id | 30C594EE-9DC2-4B50-8991-16E4739677AA@easesoftware.com обсуждение исходный текст |
Ответ на | Re: Polymorphic delete help needed (David Fetter <david@fetter.org>) |
Ответы |
Re: Polymorphic delete help needed
|
Список | pgsql-general |
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 thedatabase. I have not seen the term polymorphic used with databasesexcept with Rails so I will quickly describe it.You have now :)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 ofthe table to which the id applies. (That is slightly simplified).This is brittle by nature. The above link sketches out a way to makeit stable. If you have questions, ask :)The first problemof many ;)[other stuff snipped]that creates is it makes it hard to do a constrainton the name/id pair.Let PostgreSQL work *for* you instead of picking a fight with it andthen 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.
You and PFC I think are on a similar track. I need to figure out how to get Rails to do it this way. I was thinking just teach Rails about the flex_key view and then add rules for insert, delete, set. That is where I start to feel intimidated. It doesn't look hard but I've just never done it.
The other place where my knowledge is lacking is when I get a 'thing' from the database into Rails, making it an instance of a particular class. That can't be too hard though.
Let me work on this over the weekend. This is not a "for work" project. I really appreciate the help.
Perry
Ease Software, Inc. ( http://www.easesoftware.com )
В списке pgsql-general по дате отправления: