I want to create a product catalog that allows you to create complex parts for each type of product in the catalog. Product types have very different data associated with them; some of them have only common data, some with a few additional data fields, some with many fields specific to this type of product. I need to easily add new types of products to the system and respect their configuration, and I would like tips on how to create a data model for these products, as well as how to handle persistence and search.
Some products will be very versatile, and I plan to use a common interface for editing these products. Products that have an extensible configuration associated with them will receive new views (and controllers) created to edit them. I expect all custom products to have their own model, but for sharing a base class. The base class will be a generic product that does not have custom fields.
Examples of products that need to be processed:
- General product
- Light bulb
- Description
- Type (listing fluorescent, incandescent, halogen, LED)
- Wattage
- Style (enum of flood, spot, etc.)
- Refrigerator
- Description
- Make sure
- Model
- Style (listed in the domain model)
- Water Filter Information
I expect to use MEF to detect what types of products are available on the system. I plan to create assemblies that contain models, views, and product type controllers, drop those assemblies into the trash, and open applications for new types of products and show them in the navigation.
Using SQL Server 2008, what would be the best way to store these various types of products, allowing you to add new types without having to create a database schema?
When retrieving data from a database, what is the best way to translate these polymorphic objects into their correct domain models?
Updates and Clarifications
To avoid the effect of the internal platform, if for each type of product there is a database table (for storing products of this type), I still need a way to get all the products that cover the types of products. How will this be achieved?
I talked with Nikhilk in more detail about my SharePoint link. In particular, he talked about this: http://msdn.microsoft.com/en-us/library/ms998711.aspx . It actually seems pretty attractive. No need to parse XML; and there is some indexing that can be done by allowing simple and quick data queries. For example, I can say โfind all 75-watt bulbsโ, knowing that the first int column in a row is the power when the row is a bulb. Something (NHibernate?) At the application level would determine the mapping from the product type to the user data schema.
Voted for a schema that has a property table, because it can lead to many rows for each product. This can lead to difficulties with indexes, plus all queries will have to essentially merge the data.
sql database sql-server database-design data-modeling
Jeff handley
source share