I have a Rails model email_condition_string
with a word
column in it. Now I have another model called request_creation_email_config
with the following columns
- admin_filter_group:references
- vendor_service:references
- email_condition_string:references
email_condition_string
has many request_creation_email_config
and request_creation_email_config
belongs to email_condition_string
.
Instead of this model a colleague of mine is suggesting that storing the word inside the same model as comma separated values is more efficient than storing it as a separate model. Is that all right?
3
It really depends on how you plan to use this later.
You are anyway one migration (and some code changes ofc) from changing this solution from one to the other. So I would choose whatever, and later benchmark it in a way your users really use the system.
Even better – profile the app and look for bottlenecks first, instead of optimizing it prematurely.
If you use PostgreSQL or Oracle one more option is to use array type instead of serialized string. It could be it’s more efficient with indexing such type. Or you may want to use full text search solution later.
To summarize – it depends on how you utilize this data and how big the data set is.