Inherited Entities

Posts   
 
    
Posts: 116
Joined: 18-Feb-2006
# Posted on: 28-Feb-2006 22:55:49   

I have a question about the design of one of my entities:

Let's say that I have an SUV Class and a MiniVan Class and a Sedan Class. They all inherit from an AutomobileBase class. My database contains a table called Automobile that contains all the data for SUVs, Minivans and Sedans.

Say I am adding a new SUV, I first add all the properties to the object and then call ADDNEW. ADDNEW will call the base class ADDNEW to add the base information and then update it with the SUV information.

Is this a good design or should each of the "types" be put into their own table to control?

How would LLBLGen handle this Inheritance from a Base Class? Is a different design better?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 01-Mar-2006 03:49:10   

The advantage of the different tables method is that you wouldn't need null fields in your tables that are not shared between the Automobile types. Read over the Concepts - Entity inheritance and relational models section of the manual for a bit more information on the different implementations of the inheritance. If you have it setup then you should just have to create a new SUVEntity and then save it. On the save the fields for the entity will be written into the correct tables without you having to create any special code.