Reputation: 67
I currently am working on developing a blogging website. For this application we're using MySQL as the database. For this application,I created a blog table which contains the following properties:
I want to add tags to this table. What is the recommended way of adding tags to this table so that in the application I can search for articles/blogs based on tags ?
Upvotes: 1
Views: 2660
Reputation: 938
It is common to use many-to-many relationship for tags. In your case it can be a couple of tables:
tags
tag_blog
You can set combination of (tag_id, article_id) as primary key. In this case it will be guaranteed that tag can be mentioned only once for the given article.
Upvotes: 4