Reputation: 6943
I am using ASP.NET MVC5, Entity Framework, Web API 2, OData, MSSQL backend; a pretty standard MS stack I suppose... and wondering: What's the best setup / structure for a simple blog system with regards to "Tags"? Should I store each tag in a Tags table as a new row? Or is there a better / more efficient way? It might be worth mentioning that I may also wish to use tags in other parts of my site later (perhaps in the CMS pages I have and so forth)... so I need to think of the best way to make this efficient and extensible.
Upvotes: 2
Views: 106
Reputation: 82474
Use a simple table for tags:
TblTags
-------
TagId int (pk, identity)
TagName varchar(30) (unique, or nvarchar, and use whatever length that suits your needs.)
Then use an intersection table with tags and whatever, for example blog articles:
TblTagsToBlogArticle
--------------------
TTBA_BlogArticle_Id
TTBA_Tag_Id
Note that the primary key should contain both columns of this table.
Upvotes: 1