Possible Duplicate:
When to use comma-separated values in a DB Column?
I want to create similar articles script. My idea is that articles would be similar by ID. For example if article have ID = 1 for this article, similar article will be with similar_id = 1
Table example:
ID Similar_ID
1 0
2 0
3 1
4 1
Article with ID 1, will have 2 extra articles with ID 3 and 4.
How to model table if there are more than similar ID ?
Example:
ID Similar_ID
1 0
2 0
3 1,2
4 1,2,3
You should use two tables, the original one you have above, and a separate one that has one row per Article-Similar Article.
So your original table would be: Articles
And your other table would be as you have above: ArticlesSimilar
You would ensure that the combination ID-Similar_ID were UNIQUE.