RE: PyDO2 inheritance ..

"Dongen, Jeroen van" <[email protected]> Fri, 3 Jun 2005 10:40:53 +0200
Newsgroups gmane.comp.web.skunkweb
Message-ID <[email protected]>
In addition to Jacob's otherwise correct reply: you can also model
inheritance using *updateable* views, both Postgres (by means of rules)
and Mysql
(native?) support this in recent versions.

Thus you would have a table Person and a table Staff and an updateable
view v_Staff which links the person and staff table together by primary
key. (i.e. create view v_staff as select person.*, staff.* from person,
staff where person.id=3Dstaff.id, in postgres add rules for translating
updates/deletes/inserts etc. on the view to similar actions on the
underlying tables)

The PyDO class Staff table attribute then should of course point to
v_Staff.

This way of doing inheritance has the benefit of keeping the relational
model completely intact (as opposed to the native Postgres model). Only
problem is that you can't (easily) do multi-column/field uniques if the
various columns/fields are part of different tables. But that can be
done using triggers if you really really need it.

Generating the views etc. is a big pita though, so I have written a
script that given a PyDO class definition generates the various views
and rules. So you model the database like you would normally do, model
the PyDO classes the way you normally do and then run the view
generator. Works only for Postgres by the way.

Code and example are in the linked zip (could not attach it, as SF does
not allow that anymore).

Although I have not tested the specific case yet, but at first sight it
should not be too difficult to make it work with the introspection
stuff.

http://www.baasbartels.org/software/views.zip

Rgds,
Jeroen


-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005