3 ms·
How easy is it to use standard SQL to join, project, and query on columns within the JSON fields? For example, with something like SpringData JPA (and probably
by hiram112 9y ago
How easy is it to use standard SQL to join, project, and query on columns within the JSON fields?
For example, with something like SpringData JPA (and probably other tools in other languages), I can create methods like
findUnitTypesWithMaxSqftGreaterThan(int size)
The framework is smart enough to deduce the fields and create the necessary SQL data and make the query.
Similarly, a lot of tools can do things like generate data objects based on columns with correct types and constraints.
I'm hesitant to start using JSON too much, as then I'm back to the same problems we've got with other NoSQL dbs like Mongo - basically our code is a jumble of marshalling json to objects where one never knows if fields are null or empty or any random type of data.
- dcposch 9y agoQuite easy: select * from unitType where info->>'$.maxSqft' > ? If you want it to be indexed for production use, that's also pretty easy: alter table unitType add column maxSqft float as info->>'$.maxSqft' alter table unitType add key(maxSqft) ... select * from unitType where maxSqft > ?