I am developing a Ruby On Rails App for collecting data from users for products via web forms. A database table contains all the ProductTypes, another table contains ProductAttributes, and ProductTypes_ProductAttributes is a relationship table mapping the attributes that are assigned to certain product types. The data collected for each specific product is then stored in a Products table (with a column/field for each attribute - which may be empty if that attribute is not relevant to the product).
I want to add a feature to allow Administrator users to add new ProductAttributes to the system and then assign them to certain ProductTypes. No problem except when it comes to persisting the specific products collected. This will require dynamically adding a new attribute field to the Products table at runtime. This is where I'm a little stumped as the best way to do this...
1) Store the products in an XML doc... This will save having a bunch of empty fields in the DB for attributes that don't belong to the ProductType for that product, and means new attribute types can be saved no problems. I'm a little weary of storing data in XML files though, I've always regarded them as a means to transmit and move data, not store it.
2) Continue to use a RDBMS, but include a BLOB field to store the attributes which can be dynamic for a product in XML, while traditional fields remain for the product code, description etc etc.
3) Finally, is there a RDBMS solution for the above? I've seen some discussion about MongoDB but I'll admit I'm really not familiar with it having a background in more traditional DB's.
Was wondering if anyone has any experience and tips regarding this they would like to pass on? I'd like something that integrates with Ruby on Rails, and allows dynamic adding of persistence fields without requiring any code changes when a field is added to the DB table?
Cheers,
Steve