I want to create a simple tags system using php and mysql, so that users can add few tags via form. My question is that should i save the tags as an array in single database column? eg. "tag1, tag2, tag3".. or i should have separate columns in database table where i should save each tag in each column.
i hope my question is clear.
Thanks.
解决方案
I would probably say neither. Use a many-to-many relationship between tags and the object being tagged. For instance, if the thing being tagged is a question, the tables could look like this:
Question:
QuestionId
Title
Body
Tag:
TagId
Name
QuestionTags:
QuestionId
TagId