I am working on a requirement where product needs a flexibility to add Lists of multiple number of columns. I am trying to fit data in data model with the help of key value pair.
For example -
I have a list Allergy which will have 3 columns Allergy, Reaction and Type Another list named Lens have only two columns Vendor Name, Cost
My model consists of following table
- LIST
It consist of LIST_ID and LIST_NAME
- LIST_ROW_MAP
It consists of LIST_ROW_ID, LIST_ID ( Foreign Key to LIST table) , ORDER ( to save row order)
3 LIST_ITEMS
It consists of LIST_ITEM_ID, LIST_ROW_ID (Foreign key to LIST_ROW_MAP table ) , KEY , VALUE
(Sorry could not post picture as I do not have privilege yet)
Though I can save the data, for retrieving I am facing challenges. I tried query marked as answer in below link but it can help when name of columns are known and when it is for single table stored as key value.
Transposing a Key Value pair SQL table
I am trying to store multiple table's data so there should be something dynamic. Please help :)