I am looking for conceptual solution for my problem and advise on using the most appropriate technology.
I have database which consist of one table (id,name,…) In the functionality of the project it is required to add comments. While previewing object there will be space provided for all the comments.
Should I create another table with id as primary key and another column called comment ?
If so, having two or more comments describing the same product (and sharing the same id) is plan wrong
Should I better use some XML file and try to build something like:
<allobjects>
<object id=1>
<comment>blaah blah </comment>
<comment>something</comment>
<object id=2>
</object>
</allobjects>
and then loop through xml structure and retrieve comments ?
I wouldn’t put this in an xml string to then parse it. If the product is to have one and only one comment, then adding another column to the product table might be a good approach. If you ever plan to support multiple comments to a product then makes more sense to have this stored in a separate table. Similarly, if not all products are to have a comment, it’s best if you add another table. The most flexible solution is to create the new table. Storing this in an XML document does not seem too practical, specially because you’ll have to parse the xml which will be considerably slow(er) compared to retrieving it straight from a table.