3

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.

asked May 19, 2013 at 13:54

1 Answer 1

1

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.

answered May 19, 2013 at 14:10
Sign up to request clarification or add additional context in comments.

6 Comments

Please read my P.S above, while the user is making the table, no id exists, the product is not submitted yet, so how should I relate the table to the products table?
When you write your insert code you create the product first, return the id for the product created and then populate the details table. I'm not sure I'm understanding what the issue is here?
in your way, in server side when I get the product_id, I have an HTML table! how I'm supposed to parse that HTML table and detect main subjects, titles and descriptions...?
You're going to have to create form inputs and post those back to the page doing the work. You haven't stated what language you're using PHP, ASP.NET etc so there really isn't much beyond that to be added. Whichever language you're using it's just a matter of separating the $_POST variables when processing the form to save to the proper table. Your question was a conceptual one and now you're asking for code?
You could see the language while you see my question tags, and I'm not asking for code :-) , thanks anyway
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.