VirtApp VirtApp - 1 year ago 71
SQL Question

Why Json into db?

Why some companies today are using the approach to save json objects into a DB instead creating new table and store data in it?

What are the real advantages?

Answer Source

In my company we use JSONB in Postgres database because of the need to store dynamic column data which will not fit into a traditional relational model since number of columns would grow all the time or we would have to have columns without meanings and assign those meanings based on some other columns that would identify row values which in my opinion calls to heaven for forgiveness.

I find this approach also better than the typical Entity-attribute-value model for performing lookups and generally understanding the data. This opinion is also shared by analysts at my company who have also been working with EAV model in the past.

Greater percentage of our data fits into relational schema design and since there was a need for NoSQL approach which isn't actually the majority of data (nor is it a completely schema-less table) we decided to stick with Postgres instead of complicating things and moving small percentage of our data to different (example: document) database.

Since 9.2 a lot has changed and Postgres offers a great support for optimised searches within json and jsonb columns.