mysql - Best way to store an array of data associated with a post in Rails -
so have mysql-powered rails app has post model, , want each post have list of keyword associated it. keywords specific , rare 1 keyword shared between 2 posts.
there 3 options here:
- a comma separated list in "keywords" attribute
- have serialized array in "keywords" attribute
- build keyword model , store each keyword under own record , associate them posts id
which best solution , why?
if want search tags, 3, because otherwise have or instantiate every object in search, or sql query ugly.
if don't want query tags, serialize make readable , avoid table (and eager loading) that.
Comments
Post a Comment