alepou77 Posted December 29, 2013 Share Posted December 29, 2013 Hello everyone,I have "Posts" table in my model. "Posts" table have these columns : ID , title , image , category , description , body , author , created_date. I want to extend my "Posts" table by adding a column "tags". I want my php website to compare one post with others by "tags". Is it this option good? or I must make a different table with foreign keys and tags. Please anwser me if you can the mySQL queries and the right database Model. Thenks Link to comment https://forums.phpfreaks.com/topic/284959-mysql-query-for-posts-tags/ Share on other sites More sharing options...
Kerzo Posted December 29, 2013 Share Posted December 29, 2013 Your best bet is to have three tables: 'posts', 'tags' and 'post_tags'. The structure of the Posts table remains the same. Tags is comprised of tagID and tagName columns. Post_tags links the tags in the Tags table to the appropriate Post using foreign keys on ID and tagID. This means that a post can now have multiple tags connected with it, retrieving other posts with the same tags is a lot quicker and it can also be done in a single SQL statement. Link to comment https://forums.phpfreaks.com/topic/284959-mysql-query-for-posts-tags/#findComment-1463224 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.