开发者

Best way to implement keywords for image upload gallery

开发者 https://www.devze.com 2022-12-27 05:03 出处:网络
I\'m starting to spec out an image gallery type system similar to Facebook\'s.Members of the site will be able to create image galleries and upload images for others to view.Images will have keywords

I'm starting to spec out an image gallery type system similar to Facebook's. Members of the site will be able to create image galleries and upload images for others to view. Images will have keywords the the uploader can specify.

Here's the question, what's the best way to model this? With image and keyword tables linked vi a HABTM relation? Or a single image table with the keywords saved as comma delimited values in a text field in the image record? Then search them using a LIKE or FULL TEXT 开发者_JAVA技巧index function?

I want to be able to pull up all images containing a given keyword as well as generate a keyword cloud.

I'm leaning toward the HABTM setup but I wanted to see what everyone else though. Thanks!!


I'd highly suggest a HABTM relationship. IMHO, storing multiple fields in one column (e.g. comma delimited tags) is a terrible idea... Think of the nightmare you'll have in searching multiple tags, or if the keywords were input in the wrong order! Also, generating a keyword cloud would be nigh impossible if you don't have a keywords table.

So yea, I guess that's my 2 cents :D

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号