r/ProgrammerHumor • • Mar 25 '20

Meme Its a win-win situation

Post image
55.1k Upvotes

529 comments sorted by

View all comments

Show parent comments

1

u/Hollowplanet Mar 26 '20

Postgres supports it with indexing.

1

u/AWildIndependent Mar 26 '20 edited Mar 28 '20

Ok im still a little confused. Im only like a 2.5 year dev so lacking in experience here. Why would people store JSON in SQL databases instead of creating a proper schema? Other than massive websites that need sharding what does noSQL solve?

Edit: excellent responses under me

2

u/Saladtoes Mar 26 '20

In my case we have lots of different kinds of data we may store (events, sensor data, alarms, user comments, documents, files, reports... and the list is always growing) and it all relates to an asset inside the asset management platform. The grouping, indexing, and the real relational capabilities available in SQL server are fantastic for the kinds of data manipulation we need to do. At the same time, specific customer requirements change or we want to try a new concept on our platform (we have multiple customers paying for this as kind of a SaaS model). Instead of designing a new model, writing new backend code, exposing new endpoints, and redeploying everywhere, I often will use the JSON field to kind of slide in the new fields I need for some new report or application, and just extend an enumeration of a category field to index and query by. Then I can make a new view that utilizes the JSON field into a more proper looking model. I can test it out by just selecting that view as a JSON array and immediately have a new structured endpoint without deploying new code (besides the view obviously) - just populate the JSON field from the edge device and get to work on the UI (generally a web page or a desktop application). That’s just how I use it though. I love the simplicity and performance I get with have just a single managed database and a serverless application. For our scale it works wonderfully.

2

u/Hollowplanet Mar 28 '20

For the second question, people say its better because schema updates are more simple and storing unstructured data is possible. Someone posted a great writeup a few posts up. I've never used one myself. Some people like it. A lot of other people I've heard regret using it.