Re: [Modeling-users] Re: Implementing inheritance through vertical mapping
Status: Abandoned
Brought to you by:
sbigaret
From: Federico H. <fh...@vi...> - 2003-09-25 17:18:00
|
On Thu, 2003-09-25 at 10:37, Sebastien Bigaret wrote: > I can't remember if it's been discussed here, however this is the way > I think this could be done: > - models: add support for flattened attributes and > relationships. Flattened properties are exactly this: take the value > for a given field from another entity (hence potentially from another > table). Flattened properties will be declared with a simple path, > such as: toEmployee.toStore.name > (BTW, backward-compatibility should, and will, be ensured) OK, so what we're talking about here is that the XML is a description of the *classes*, and how they map to the database, not a description of the database itself (i.e. "entities" declared in the XML are "class" entities, not "table" entities). No problem with that, I'm just trying to make sure we're talking about the same things. In this way of handling things, the XML will never reflect inheritance, and all classes that are part of an inheritance hierarchy will have to specify the flattening of each attribute. This makes writing the XML by hand a major pain in the neck, though it probably doesn't matter (at least to us, we're planning on generating this XML from our own, richer XML dstabase schema description). > - make the framework correctly handle those flattened properties. As > far as I can see, this would only impact the low-level bricks of the > framework (esp. SQL generation for fetching and saving). I agree, this should be pretty straightforward, and could be implemented without breaking anything... people who don't use it wouldn't even notice it's there.=20 > Could you possibly elaborate on that? I never played with postgresql's > inheritance support, and it's probably something that could be added in > the User's Guide until vertical mapping is supported. If you find some > time to illustrate the mechanisms, I'll be interested in learning how > they behave wrt. the framework. Well, I haven't done much work with it personally either, but one of my pals here has. The story is that you can specify inheritance in a PostgreSQL database scheme. When you tell PostgreSQL that table Mammal inherits from Vertebrate, a "SELECT * FROM Mammal" will include all fields defined in Vertebrate as well. The interesting part is that the Vertebrate fields are actually stored in their own table... think of it as vertical mapping implemented in the DBMS. So unique indentifiers are unique across all Vertebrates, regardless of whether they are Mammals or not. I have not tried this yet, but it looks to me that this could be used to put our application (which uses vertical mapping) in such a state that it can be used with the current framework. Fede |