Victor
Victor

Reputation: 13368

Store as JSON or separate attributes?

I'm using Rails 3.2 and MariaDB. I have this group of data:

description, services, facilities

Not indexed and purely for output in the show page. Should I store these as one JSON object in one more_info attribute or store as separate attributes?

Upvotes: 1

Views: 76

Answers (2)

Griffin M
Griffin M

Reputation: 461

I personally would make columns for them, it would generally make the fields easier to work with, especially if there will be need a to update the values. I usually reserve JSON serialized fields when I do not know how many attributes there will be.

Upvotes: 2

Gavin
Gavin

Reputation: 516

If you are showing the data to your users I would recommend saving them in different columns. I find that as soon as users see something they want to filter by it or work with it in ways you have not foreseen. If you are not then the choice is less clear cut but the very fact you have 3 distinct groups suggest that they are different things which could be treated differently as your application matures. I would always go with the Normalised form unless you have documented reasons not to.

Upvotes: 0

Related Questions