Comments (2)
Hey @naps62,
This rule predates me but I can share some thoughts around the ideas behind it.
Performance (which you touched on) can certainly be an issue when querying large JSONB columns, and indexes on JSONB columns are also more expensive to generate are take up more space. Heap Analytics has a good article on the performance tradeoffs.
But the spirit of this rule is more about encouraging thoughtful data modeling. Storing data in a JSONB column results in a data model that is less well-defined and not as strongly typed. If any identifiers to other models or resources exist in that data, we lose referential integrity.
I'm much more relaxed about it. Usually I'll store anything that is either impossible or hard to retrieve again later on, because I rarely know upfront what data I'll be needing
It sounds like in some of the cases you're describing, you have a "strong reason" to store the entire response from an external source. That might be fine! In cases like that, I usually ask myself the following questions:
- Should my database be the source of truth for this data?
- Is the data really impossible to fetch again?
- Am I storing the data just in case I need it or is it providing value?
Not knowing what data you'll need or when/where you'll need it may indicate that you haven't fully defined the problem you're trying to solve, or haven't fully defined your data model. It could also mean you're storing data just in case, which can get expensive.
I believe this rule also makes the distinction "store an entire JSON document from an external source" to differentiate between the situation where you are storing (for example) an API response, and the situation where you know that a Customer
may have many dietary restrictions and you choose to store them as a JSONB column in the form {"vegan": true, "gluten_intolerant": false}
just in case you add more classifications in the future.
In the latter case, there are better ways to store that data in a relational database.
I hope these thoughts were helpful 🙂
from guides.
@WilHall thank you for the response. I definitely helped yes 🙏
It does sound like we're on the same page. Perhaps saying "I'm much more relaxed about it" was a bit exaggerated on my part. Most of the use cases I was thinking about fit under your rationale as well. I was mostly afraid there was some obscure drawback of using JSONB columns that I should be aware of, other than the more obvious ones.
That article does provide some great insight though. Thanks for sharing!
from guides.
Related Issues (20)
- Add accessibility resources to guides HOT 8
- YouTube Video Unavailable HOT 5
- Should we delete empty (seemingly duplicate) graphql guide? HOT 1
- Document SVG best practices HOT 5
- Update Backbone guide? HOT 2
- Update Ember guide? HOT 1
- Update how-to guide on feature-testing a Rails app’s Javascript? HOT 2
- Document Go Best Practices HOT 2
- Replace Ruby style guide with standard HOT 2
- Combine Best Practices and Style guides HOT 3
- Our testing guides are ruby/rails-centric HOT 2
- What layout should we suggest for test suite files in JavaScript / TypeScript projects?
- Audit guides for potential improvements
- Guides have inconsistent formatting
- Data guide should use description lists HOT 4
- Change master to main in thoughtbot/guides HOT 4
- rebase workflow link missing from Git guide HOT 1
- 404 link in relational-databases
- A11y template HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from guides.