1

I want to be able to create a dynamic entity based on attributes that will be defined in another entity. For example:

Entity:Lifeform Attribute->name:String

Entity:LifeformCharacteristics Attribute->name:String Attribute->type:String

Entity:DynamicCatalog

So the characteristics entity will be a entity that will be populated by whatever the user adds. An example characteristic could be name:Height type:Number. So these characteristics define what I want the dynamic catalog to be. As such the DynamicCatalog should be created with the attribute Height.

The DynamicCatalogs will also have to be visible in a table so the user can add and remove items to the catalogs.

I can build and manage the first 2 entities via my DataModel, but the 3rd is dynamic and I'm not sure how to go about it. I was hoping to use core data to keep the headache of managing data to a minimal.

This post is the closest thing I've found to an answer, but I'm not sure now to display or reorganize a collection like this: Faking a dynamic schema in Core Data?

Community
  • 1
  • 1
mediahack
  • 11
  • 1

1 Answers1

0

Why cause yourself so much trouble?

Consider creating the DynamicCatalog type in Core Data with a 'to many' relationship to something called 'DynamicCatalogValue' or some name that rings the semantic bell. Create attributes on the 'Value' that you will allow the user to describe. For example (pseudo):

DynamicValue:
Attribute: userGivenName;
Attribute: userGivenValue;
Attribute: valueType; (e.g. String, Date, etc.)
Frank C.
  • 7,758
  • 4
  • 35
  • 45
  • Well thats kind of what the faking a dynamic schema link discusses. However, I am unclear on how that will work. Value type an be variant. What if the user wants to create a Attribute:picture which needs to be an image type. – mediahack Feb 13 '11 at 03:13
  • @mediahack - This was just a 'starter' example. In a more elaborate scheme you may model 'potential' types that have an abstract as the parent. That way you can instantiate the appropriate type from the context when the user selects the type of attribute they are adding. – Frank C. Feb 13 '11 at 14:53
  • @FrankC. could you please provide more detailed explanation or an example link? Also I wonder whether dynamic number of this field added or not? – tugce Apr 02 '13 at 07:46