Vertical table in rails
In this article i have just taken a short example describing vertical table,and its implementation using rails.
When table has no fixed column it has dynamic fields .data is not stored on separate column but data stores in vertical fashion.
For implementing vertical table table has mainly 2 columns key and value pair.key is like database column name and value contains actual data.
Lets take an e.g
Consider website in which it contains various products and its comparison ,searching and many more features.product can be mobile,car etc.Product has many items.item may be nokia 6600,nokia n72 etc.
Here our aim is not compare aur search items.Here our main aim is how vertical table concept is applied.Suppose we have to build only single product comparison site then each product has it’s own attributes that can be easily build with adding column for each product.
we are developing generic site like multiple product,so there is no fixed attributes,each product has it’s own attributes either we create different model for each product or we can proceed with vertical table concept.
- Product has many Product Attributes.
- Product has many Items.
- Item has many Item Attributes.
- Item Attribute belongs to Product Attribute.
Product Attribute mainly requires 3 fields
name : which is used for key in vertical table i.e column name
option_type : which is used for viewing different form of data when item is created like text box, drop down,checkbox,multi option
option : which contain option if its drop down or multi option i.e serialize.
Item has only name field which is optional
Item attribute mainly required 3 fields
name : key name or column name
value : actual value
item_id : foreign key of item
It is used where table has dynamic fields , and it only concern with data.
Here data grows vertically.
It has mainly key ,value pair.
Source code of above example is hosted on github http://github.com/amardaxini/vertical_table_demo
For More info about vertical table you can visit http://weblogs.foxite.com/andykramek/archive/2009/05/03/8369.aspx