Now i met a problem on the database model, I have a standard database model. Because the requirement get changed, i want to extend the standard model.
Directlly, i want to add some columns into a table in the database every time, and i don't know what i will add in the furture, that is to say, i don't clear the added columns now.
This is like inherit model in java.
I mean i wil add columns in the company table when the program is running. You know, the running program have to be added by the mean of alter table command, but now i will add some columns for this company and add others columns for that company into the company table, which is existed the standard columns.
Obviously, i wll add different columns for company respectively, which is a standard table.
Who can help me ! ???
Thanks in advance!
here you meet the restrictions relational databases force on object oriented design and implementation.
If I were you, I'd try to port my app to an OODBMS (like, for instance, FastObjects - www.fastobjects.com), which would be easier if you had used JDO as your persistence API in the first place...
In the end, this will reduce the code overhead you have to create to manage inheritance on your own enormously.
I frankly don't know about OR-Mappers like Castor (castor.exolab.org, if I remember right), because they seem counterintuitive to me :o)
Otherwise, you could as well try and store additional, varying data in special tables (one for each subclass) and store the common data of the superclass in one standard table. I gather this could mean lots of joins when selecting data of an instance at the end of the hierarchy...
Hope this helps,
You can't really. But you can extend tables via joins and store them into views. Some database platforms can really do some amazing things with stored procedures as well.
I think you have to use a database that supports object-oriented
features... Postgresql comes to mind.
See the documentation about Inheritance