Re: Polymorphic delete help needed

Поиск
Список
Период
Сортировка
От Perry Smith
Тема Re: Polymorphic delete help needed
Дата
Msg-id 1FCAEACB-AF85-4F68-9A3A-4B387C16227D@easesoftware.com
обсуждение исходный текст
Ответ на Re: Polymorphic delete help needed  (PFC <lists@peufeu.com>)
Список pgsql-general
On Jul 6, 2007, at 8:23 AM, PFC wrote:

>     The advantage of my approach is that :

[ snip -- all very good stuff ]

I think I can make something like this into Rails fairly easy.

>     Hm, another reason why I don't really like the Rails approach...
> do they at least use unique IDs ? Please say yes ;)

Yes.  Rails makes it really hard NOT to have id's -- but you can if
you need t hook into existing databases.  But, two things: 1) Please
don't infer what Rails can and can not do from me.  I'm new to
Rails.  2) The single inheritance is one approach.  The polymophic
way (that I described first) is an unrelated approach.
.
>> But doing what you are doing, I believe I can very nicely fit into
>> Rails and (obviously) PostgreSQL.  Plus, your suggestion of moving
>> entries to a "trash" bin seems very wise.
>
>>>> The first problem that creates is it makes it hard to do a
>>>> constraint
>>>> on the name/id pair.  I thought about writing a function that would
>>>
>>>     Is this ClassName / id only found in the "main" table or is
>>> every FK implemented as a ClassName / id pair ?
>>
>> The ClassName / id pair is found only in the relationships table.
>> There are two instances of it however: parent and child.
>
>     I believe duplicating the ClassName and storing it everywhere to
> be bad. With my approach you only need to use the id in reference
> since two instances of the same base class cannot have the same id
> regardless of their class, and you only need the id to instantiate
> a row, whatever its class.

This is really big to me.  I did not mention it but I have a
constraint currently implemented in Rails that two things that have a
Relationship, must have a relationship that comes from another
table.  So A can relate to B only if the link_types table has an
entry from A to B.  So, I have duplicate information sprinkled all
over.  That is partly my fault but it is also, as you point out,
partly the way that Rails puts the type in the Relationship rather
than down in a common table.  The common table approach makes so much
sense.

I need to go back and re-read how Rails does single inheritance.
Maybe I got that all confused.  Because, really, that is what all
this is flowing back to create.

>
>     If you want to specify that a class instance can only have
> children of specific classes (or their subclasses), for example a
> FriendList can only contain instances of People, or whatever, you
> can use a constraint trigger which will check the class of the
> referenced row against a table describing the allowed parent/child
> combinations.

I kinda have this but it is implemented up in rails, not down in the
db where it would be more efficient.

I replied to David as well.  You both have similar ideas.  I will
work on this over the weekend and I hope I can give an update when
I'm done.

Thank you very much.  You have helped me a lot.
Perry Smith ( pedz@easesoftware.com )
Ease Software, Inc. ( http://www.easesoftware.com )

Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems



В списке pgsql-general по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Nested Transactions in PL/pgSQL
Следующее
От: "Knut P. Lehre"
Дата:
Сообщение: REVOKE "ALL FROM ALL"