Re: [Modeling-users] Re: Implementing inheritance through vertical mapping
Status: Abandoned
Brought to you by:
sbigaret
From: Mario R. <ma...@ru...> - 2003-09-27 09:44:49
|
Hi, sorry about the late jump-in, just a few comments: On Jeudi, sep 25, 2003, at 21:36 Europe/Zurich, Sebastien Bigaret wrote: > Federico Heinz <fh...@vi...> wrote: >> On Thu, 2003-09-25 at 10:37, Sebastien Bigaret wrote: [...] >> 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). > > XML-models have no default value, in fact they are a comprehensive > description of the models, so in general designing them by hand is a > pain --that's why the ZModeler was written, and also why PyModels are a > great win :) Note that in PyModels, properties do not need to be copied > from parent to children, this is done automatically. I see the XML just as an exchange format for a model, if you need to import, generate or export a model definition _programmatically_. IMHO, to develop your XML by hand is silly, as it is ugly, way too verbose, and very obscure and un-expressive -- it is very difficult (for me ;) to visualize a model from its XML definition. So, the XML should only be manipulated by tools -- in which case it does not matter whether properties are flattened or not. However, if one still wants a more human-friendly XML, what's the problem with either assigning generic default values for xml element attribs (e.g. parentEntity='', isReadOnly='0', isAbstract='0', etc, if not present), or "inferring" the value of specific attribs from the parent entity if one is set. Elements are "identified" by they nodename and by the value of the name attribute. For example, the famous Employee entity can become (leaving out PK, and Rels for simplicity) : <entity name='Employee'> <attribute width='50' precision='0' externalType='VARCHAR' name='lastName' scale='0' type='string'/> <attribute width='20' isRequired='0' precision='0' externalType='VARCHAR' name='firstName' scale='0' type='string' /> <attribute ... name='fkStoreId' ... /> </entity> And, if we now declare SalesClerk, that inherits from Employee, we could get away with: <entity name='SalesClerk' parentEntity='Employee' > <attribute width='20' precision='0' externalType='VARCHAR' name='storeArea' scale='0' type='string' /> </entity> The default values are more "limited" than in PyModels, as they apply to nodeType[@name]/@attrib, and to nodeType[@name]/* (children). It is then a matter of pre-processing to generate from the above the same identical full XML for these 2 entities as in the current StoreEmp example, thus no runtime code would need to be touched in any way. The pre-processing could be done also as an XSL transformation or so, or with any old dom manipulation technique. Also, no backwards compatibility issues, as if something is specified explicitly, then it is not affected by this mechanism. But, I question whether doing all this is worth it... in the end it will still always be way more cumbersome than PyModels (also in performance!). > BTW: there is a reason why models requires properties to be copied: a > string attribute in a parent can have a width of 40, while a child > can > ask a width of 50 for the same field. Since model introspection is > something the framework does a lot, we do not want to compute > inherited attributes if they are not overriden: that's why they are > copied. And since xml-models are comprehensive descriptions of > models, > you also find copy of inherited attributes in entities. > > PyModels takes care of this when loaded, although they also allow > you to override the definitions of inherited attributes, if needed. > The best of the two worlds ;) Hey, and it can also generate the xml so trivially ;) mario |