I <3 Lamp
07-22-2008, 04:54 PM
Well I guess it doesn't have to be exclusively blog posts, but potentially articles, snippets, images, etc.
For the sake of argument lets say blog posts. Now I have 2 potential ideas but I'm not sure if there is a faster/leaner way to do this so please give me any thoughts you may have on the matter. Also note I am using composite keys just for this example, so do not debate whether they are needed.
METHOD ONE
3 tables:
tblBlogPosts
blog_post_id [primary key]
blog_post_title
blog_post_text
blog_post_author
blog_post_time
tblTags
tag_id [primary key]
tag_name
tblBlogTags
blog_post_id [primary key & foreign key]
tag_id [primary key & foreign key]
METHOD TWO
2 tables:
tblBlogPosts
blog_post_id [primary key]
blog_post_title
blog_post_text
blog_post_author
blog_post_time
tblBlogTags
blog_post_id [primary key & foreign key]
tag_name [primary key]
Obviously the second is a bit more light weight and would require one less join. However if you were to edit a blog post and remove a tag then it would be gone forever, meaning you couldn't track search results or make a tag cloud, etc for removed tags.
Any light you guys can shed on the topic would be greatly appreciated!
For the sake of argument lets say blog posts. Now I have 2 potential ideas but I'm not sure if there is a faster/leaner way to do this so please give me any thoughts you may have on the matter. Also note I am using composite keys just for this example, so do not debate whether they are needed.
METHOD ONE
3 tables:
tblBlogPosts
blog_post_id [primary key]
blog_post_title
blog_post_text
blog_post_author
blog_post_time
tblTags
tag_id [primary key]
tag_name
tblBlogTags
blog_post_id [primary key & foreign key]
tag_id [primary key & foreign key]
METHOD TWO
2 tables:
tblBlogPosts
blog_post_id [primary key]
blog_post_title
blog_post_text
blog_post_author
blog_post_time
tblBlogTags
blog_post_id [primary key & foreign key]
tag_name [primary key]
Obviously the second is a bit more light weight and would require one less join. However if you were to edit a blog post and remove a tag then it would be gone forever, meaning you couldn't track search results or make a tag cloud, etc for removed tags.
Any light you guys can shed on the topic would be greatly appreciated!