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.

  1. having array columns not flexible querying db.
  2. pulling data db faster associations.
  3. 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

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -