When should I use array columns v.s. associations in rails -
since rails 4 , postgres 9, array column
introduced. tried using array column store tags
or categories
, don't change , used reference / facets searching. asked question querying array column, , 1 of answers mentioned never use array store data. confused why array column created if suggested never use it. question is
when considered better use array column v.s. model associations in rails?
from experience, retrieving , manipulating data array columns slower. prefer associations.
- having array columns not flexible querying db.
- pulling data db faster associations.
what if store book's categories in db array , decide change name of 1 of categories?
having association it's change of
category
's instance name, because it's connected other instances (books example)id
. array you'll have iterate on whole collection of books update category's name.
i go using array
, json
or jsonb
column storing metadata if association overkill.
Comments
Post a Comment