Considering scenario of an Inventory Management System. Inventory has many types of items, each with own table and columns. One, two or Twelve tables are not sufficient to describe the plethora of the TYPES of items as they are extremely varying. e.g. some attributes of a family of items like BIKES do not have the same attributes of CARS. It is tedious for developer to take into account the thousands of the TYPES of items and incorporate them into each model manually.
Is there a way for users to generate models themselves? thereby generating own SQL tables etc... Is there another approach to this problem? (Maybe using Semantic Web Technologies)
Coming from Spring Framework, I am fairly new to RoR development.
Thanks in Advance.
I'm not an expert, but you could do it with regular, pre-defined models.
Item_Type
Item_Attribute
Item
Item_Type would have a name variable (not unique), and perhaps any other common attributes you'd want. It would then have a
has_many Item_Attributes
relationship, whereasItem_Attribute
belongs_to Item_Type
.So I'd make a view that allows the user to add new
Item_Type
s and then defineItem_Attribute
s for those item types.Then you could have the actual
Item
model, each instance of which is the existence of anItem_Type
in the inventory.Item
belongs toItem_Type
, andItem_Type
has_many
Items
, andItem
cannot have a nullItem_Type
.So a user creates a new
Item_Type
with the name "BIKE", then adds severalItem_Attribute
s to it, such as "Mountain" and "Red". Then the user can create a newItem
that has a relationship to the "BIKE"Item_Type
.If they wanted to add a blue mountain bike instead of a red one, they would need to go through the process again, adding another
Item_Type
of "BIKE" except adding "Blue" as an attribute for the new instance ofItem_Type
'sItem_Attribute
s.