Subtypes that have properties

Posts   
 
    
Posts: 116
Joined: 18-Feb-2006
# Posted on: 25-Apr-2006 05:20:01   

I am trying to build my application using the Target-per-entity Hierarchies and have a couple of questions:

  1. In my previous application, I had a table that listed the different sub types of a "Course" Entity (Sub type examples such as "E-Learning", "Instructor Led"). Each sub type had a specific icon and other properties that were the same for each sub type. Where can these be specified? I wouldn't think they are a part of each sub-type since it's a property of the "Type". Any thoughts?

  2. How can I get a list of the sub types for a supertype? I currently have a search page that lists all of the types and will filter the results based on the type. Has anyone implemented this? I want to add it as a filter to a TypedListDAO.GetMultiAsDataTable.

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 25-Apr-2006 09:42:38   

If your subTypes have the same properties but only different in data, then I think you don't need a Inheritance heirarchial model.

Just use a simple Courses (superType) table with all the properties that references a lookUp table of the different types (ID PK, Name, Icon) or (Name PK, Icon)

Posts: 116
Joined: 18-Feb-2006
# Posted on: 25-Apr-2006 19:20:19   

They do have different data/fields that are necessary for me to use the hierarchy.

e.g., an ILT has MinStudents, an Elearning has a LaunchURL, etc. But the ILT has a different Icon than the ELearning

This does bring up another issue. If I flatten this table out, can 2 subtypes use the same field in their definition?

e.g., ILT has minStudents, On the job training has minStudents, but eLearning does not. They all inherit from Course.

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 26-Apr-2006 15:27:48   

Each sub type had a specific icon and other properties that were the same for each sub type. Where can these be specified? I wouldn't think they are a part of each sub-type since it's a property of the "Type". Any thoughts?

Place common properties in the SuperType and different properties in subTypes.

  1. How can I get a list of the sub types for a supertype?

I guess you may use the EntityType Enumuration to get instances of each entity type by reflection, then You can check if this type "Is" of the superType type.

This does bring up another issue. If I flatten this table out, can 2 subtypes use the same field in their definition? e.g., ILT has minStudents, On the job training has minStudents, but eLearning does not. They all inherit from Course.

If you use one table, then there is nothing wrong of using the same field in more than one type. And if you use TargetPerEntity model, there is also nothing wrong to have the same field name defined in more than one subType.

Posts: 116
Joined: 18-Feb-2006
# Posted on: 26-Apr-2006 19:33:25   

Perfect.

I didn't want to change my schema from it's current state (flattened) to be able to use sub types. For some reason, I thought I had read that you can't use the same field in different subtypes.

Thanks for the clarification.