Stackoverflow allows a poster to make tags for their questions.
Now say I have some articles and want to give some keyword tags to each. I’m using PHP and mysql for this.
What is the best database structure to use when doing this?
Will a limit of 5 keywords per article and unlimited keywords cases require different database structures?
It is best to normalize your database. You won’t find better.
articles:
article_id, blablabla
tags:
tag_id, title
tags_to_articles:
article_id,tag_id
In any case it is best to normalize your databases. Always. Don’t worry if you will change your mind and do the limit of tags. Above structure will be always the best because of smallest amount of memory to use.