Re: [Modeling-users] Re: Implementing inheritance through vertical mapping
Status: Abandoned
Brought to you by:
sbigaret
From: Federico H. <fh...@vi...> - 2003-09-30 00:37:30
|
On Fri, 2003-09-26 at 19:05, Sebastien Bigaret wrote: > The framework needs to be in control of the mechanism generating the > primary keys --it needs to know the PK in advance so that > relationships (FK) and other changes can be changed in a single > roundtrip to the database. I know... this can be a bummer. In other instances when I had to solve this problem, I added to the driver a function that would return the PK assigned to the last insert (most DBMSs offer this one way or another, so a function in the driver can be used to unify the API). I would then assign a temp primary key to any new objects, and use it as a foreign key. Then, when the final PK is assigned, I'd go back and change the bogus foreign keys. It gets the job done, and it doesn't rely on additional tables on mysql and friends. On the other hand, it does require quite a bit of internal bookkeeping, so it may well not be worth the trouble. > I'm not really advocating it, it's just that I never played with it > because I considered a bit slower than horizontal: with 'nb' classes and > subclasses, [...] I never tried it --but my opinion has no real > weight here, remember I'm really not good at sql: that was one of the > motivation for writing the code :) Doh! And I was looking up at you for enlightenment! :-) Anyway, this may be a very good chance to compare horiz- vs vert-mapping, and see how they fare, don't you think? > You're perfectly right when you say > that the db will not be the bottleneck, the time taken by the framework > to build and manage the object graph will be greater anyhow. Indeed. But of course, when you have a few dozen hundred clients doing queries, things may look different. This is something we will have to find out sooner or later :-) > BTW if you have precise SQL examples on how you optimize the fetching > and updating of objects in a vertical mapping that could come in > handy! There's not much to optimize, actually. All you can do is cache the join sentence needed to fetch a given class, and create it carefully so you don't fetch unnecessary stuff nor check for redundant conditions, all of which is pretty straightforward... Fede |