I am designing a web app which the users could post their products into it, each product will have a section as "Technical Specifications".
This is like:
Subject 1
Title 1: Description 1
Title 2: Description 2
Title 3: Description 3
Subject 2
Title 1: Description 1
So for example TV could get something like:
Main Details
Size: 18 inches
Color: Black
Style: Wide
HD: Yes
Supplementary Details
Guarantee: Yes
Support: No
The above functionality has been made by jQuery, there are + buttons in my page, the user could add new Subject with sub items, so he could have 4 main Subject, each of them could have as many as the user wants sub details.
Now the question is, how I should store such details in db so it could be easy to edit and search? currently I'm storing the table HTML data into db but it doesn't sound wise.
P.S: While the user is defining the details, the product is not inserted to db YET, so I need to keep data on the fly and insert them after the user submitted the product.
Thanks for your help.
If I'm understanding you correctly you'd need two tables for this.
Subject table
- subjectId
- subjectName
Details table
- detailsId
- detailsName
- detailsNote
- subjectId
This would be a one to many relation where you would have only one subject entry per table but as many details entries as necessary, then when reading the data back you'd just load both tables via a join on the subjectId.