Data Requirements:
Asset is a basic entity in the system.
Each asset has a set of attributes associated with it.
Two or more assets can share same set of attributes OR an asset can have altogether a unique set of attributes.
Attributes are not predefined for all assets. For most of the assets, we can think of a basic set of attributes that depends on the asset type. After that each individual asset can add a different attribute for itself.
Database Design:
I want to put asset data into a single table. But then every asset can have different attribute names with different data types - I cannot put this information in the same table.
I am thinking of making one asset table with basic set of attributes along with the asset type information.
Asset (asset_id, asset_type)
Next I can make several tables depending on the number of asset types (in the system) each with the basic set of attributes of related asset type.
Asset_Type1 (asset_id, attribute11, attribute12, ...)
Asset_Type2 (asset_id, attribute21, attribute22, ...)
.....
Now to accommodate the attributes those are defined dynamically as and when a new asset gets defined: I think of making tables for each possible data type like:
Asset_Dynamic_Integer (asset_id, attribute_name, attribute_val)
Asset_Dynamic_Varchar (asset_id, attribute_name, attribute_val)
.....
This will help me to enforce column constraint (if any) for attribute values.
I am not sure of this desin strategy. I will appreciate if you can go through it once and give me some insight into the design I have in mind or any other better idea.
Thank You Very Much!!!
Megha