Allowing user to create custom fields

Posts   
 
    
Truistic
User
Posts: 4
Joined: 09-Nov-2005
# Posted on: 09-Nov-2005 01:33:08   

I'm currently creating an architecture for a new product and was wondering if anyone with LLBLGen experience could tell me if it would support this type of scenario (entirely contrived but simple for brevity):

We have a parent object: let's call it Animal.
Each Animal object has multiple properties like Age, Weight, NumberOfAppendages, etc.
Each Animal also has a Type property, which would relate it to a child table of Types.
These Types would be Mammal, Reptile, Bird, etc.
This would be a required property for Animal.

All of this is fairly basic. We would like to give the end-user the ability to add custom properties to our Animal object based on type.
For example, the user might decide that for Animal Type = Bird, they want a Boolean type of Migrate. This would specify whether the animal migrates during the seasons. This would only apply to Animal objects of Type = Bird.

Users can specify zero to many custom properties for their objects. The user would also be able to specify the name of the property and broadly, its datatype. For example, int, bool, string(255), possibly allowing them to specify the size of the string, though this isn't a requirement.

The most important requirement after the implementation would be allowing the user to query objects using their intrinsic properties, but also their custom properties.

Can LLBLGen handle this scenario, and if so, does anyone have a simple example of how it would work? I have been trying with the trial edition, but have not come up with a satisfactory implementation.

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 09-Nov-2005 03:50:55   

Truistic wrote:

I'm currently creating an architecture for a new product and was wondering if anyone with LLBLGen experience could tell me if it would support this type of scenario (entirely contrived but simple for brevity):

We have a parent object: let's call it Animal.
Each Animal object has multiple properties like Age, Weight, NumberOfAppendages, etc.
Each Animal also has a Type property, which would relate it to a child table of Types.
These Types would be Mammal, Reptile, Bird, etc.
This would be a required property for Animal.

All of this is fairly basic. We would like to give the end-user the ability to add custom properties to our Animal object based on type.
For example, the user might decide that for Animal Type = Bird, they want a Boolean type of Migrate. This would specify whether the animal migrates during the seasons. This would only apply to Animal objects of Type = Bird.

Users can specify zero to many custom properties for their objects. The user would also be able to specify the name of the property and broadly, its datatype. For example, int, bool, string(255), possibly allowing them to specify the size of the string, though this isn't a requirement.

The most important requirement after the implementation would be allowing the user to query objects using their intrinsic properties, but also their custom properties.

Can LLBLGen handle this scenario, and if so, does anyone have a simple example of how it would work? I have been trying with the trial edition, but have not come up with a satisfactory implementation.

Well, off the cuff, for the custom properties it looks like a data-driven scenario which means: nothing strongly typed. You'll have tables for Animal, AnimalType, AnimalAttribute, and AnimalAttribute_Type. AnimalAttribute_Type constrains which attributes may be used for which types.

If you do want to use static attributes, you don't need to report on these as a group, and the types are exclusive (i.e., the animal can't both be a mammal and a reptile), then you would use the inheritance feature of LLBLGen Pro and create a TargetPerEntityHierarchy inheritance structure in your database (see the docs) using the FK to AnimalType as your discriminator column. This will give you static types/entities in your DAL, while retaining the custom attributes and constraints.

Let me know if that makes any sense. simple_smile

Jeff...

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 09-Nov-2005 15:48:28   

I would add an Animal_Attribute_Value table which hold the data (values) of those attributes for each animal. Values could generally be stored as strings