I'm working on an editor that enables its users to create "object" definitions in real-time. A definition can contain zero or more properties. A property has a name, a type and possibly a default value that corresponds to the type. Once a definition is created, a user can create an instance of that definition and set the property values of that instance.
So by the click of a mouse-button, the user should ie. be able to create a new definition called "Bicycle", and add the property "Size" of type "Numeric" and possibly a (default) value of 27. Then another property called "Name" of type "Text", and then another property called "Price" of type "Numeric". Once that is done, the user should be able to create ten instances of "Bicycle" and fill in the "Name" and "Price" property values of each bicycle.
This example uses only primitive property types (numeric and textual), but I want to support the following types:
- Numeric (primitive)
- Textual (primitive)
- Boolean (primitive)
- Object (compound, such as a "Bicycle" instance)
- Enumeration (a set of one of the above)
Now, I've seen this feature in several software products, so it must be a well-known concept. My problem started when I sat down and tried to come up with a DB schema to support this data structure. Does anyone know this concept well enough to give me a few pointers, or even point me in the direction of a design pattern for this? I'm planning to implement this in MySQL.
I hope I've managed to explain the concept well enough.
Update: This question has been edited and posted at stackoverflow.com instead: http://stackoverflow.com/questions/4705860/schema-to-support-dynamic-properties