35 ms·
I am becoming more and more comfortable with storing everything in JSON. With its JSON arrow operators and indexed expressions, SQLite makes a really nice JSON
by mg 1y ago
I am becoming more and more comfortable with storing everything in JSON.
With its JSON arrow operators and indexed expressions, SQLite makes a really nice JSON document store.
Assume you have a "cars" table with nothing but a "cars" column that is a JSON blob. Then selecting the models of all cars is just:
SELECT cars->>'model' FROM cars
I wish MariaDB would follow suit and also support arrow operators. You can do it in MariaDB, but it becomes more cumbersome:
SELECT JSON_UNQUOTE(JSON_EXTRACT(cars, '$.model')) FROM cars
- tgv 1y agoIf that's all, I still recommend classical columns. Now if you have array values and/or values with varying structures which you don't need to query (frequently), JSON makes sense.
- mr_toad 1y ago> SELECT cars->>'model' FROM cars Can ‘model’ be a variable, or does it have to be a constant literal?
- CGamesPlay 1y agoIt’s any expression, so a parameter or shudder column would work. https://sqlite.org/json1.html#jptr https://sqlite.org/json1.html#jptr