I am starting to make a blog in ASP.NET MVC3 using LINQ2SQL and I am wondering what is the best approach on making tags for posts.
Scenario 1:
I simply add another row to blogPosts table named tags, seperate every tag with commas and when I search for every post containing some tag I just select * where in tags it contains the text I’m after.
Scenario 2:
I add another table called PostTags and another called Tags. PostTags will contain postID and tagID. Tags will contain ID and Tag itself. Also put up DB relations between these tables.
So which is the best solution?
Scenario 2 looks better to me as it clearly separates tags in another table making the database more normalized and allowing easier querying by tags. In addition to this you will be able to more easily perform queries on those tags and show them independently of blog posts.