Sample Header Ad - 728x90

best way to store tags

3 votes
1 answer
7680 views
I'm a university student building a web application for a project with three collegues , I took the database portion. Our site is basically a link sharing site and supports tags, what is an efficient way to store tags in Mysql database ? I thought of these ways : 1- table for tags : the relation between link and tag is many-to-many so I must break it with an intermediate table, I can't think of an SQL statements to fetch links with specific tags example : the user might search for links tagged with (php , mysql ) or (hardware-issues , gigabyte). Also even if I did , it needs join , we're making the site global, that means the database will be very very huge some day , I don't think we can bare a join. 2-putting tags as an array in links table : I can put an array of strings, this means only one select statement(better than join I think) but manipulating the array will be hard, the link's poster might edit the tags on his/her link, I can figure out a way to deal with this but I'm not sure if this is the most efficient way , of course it's not normalized and the database will grow faster but I think on a server , speed is more important than size. So is there a better way ?
Asked by niceman (131 rep)
Apr 18, 2015, 10:42 AM
Last activity: Apr 18, 2015, 11:07 AM