How to Use SQLite as a NoSQL Store
rodydavis.com
rodydavis.com
Postgres goes even further than sqlite in terms of json functionality like aggregates.
And if you wanna go /even/ further you can add schemas to the json itself [1]
1: https://supabase.com/blog/pg-jsonschema-a-postgres-extension...
I agree. That's precisely how I've been managing my proof of concept projects, and it's a treat. Previously I used ORMs for the same reason, but they ended up requiring too much extra work to setup and manage.
With JSON columns, it's a matter of getting the JSON payload and store it directly, and fetch the payload and massage it in any way.
If we're already getting JSON inputs and sending JSON outputs, spending time adding and managing a whole new component to map to/from an intermediate format is something that's very hard to justify.
I was expecting something like how you can index on individual attributes like firebase.
In any case when working with JSON columns in SQL it is useful to index the documents internal fields, which the OP doesn't talk about. Found a nice example in this blog post [2].
--
There's a very short chapter in "Modern B-Trees Techniques" [2] that compare B-Trees with Hash indexes:
* Durability schemes are simple and robust for b-trees, not so for hash maps.
* Ordering has advantages for concurrency control by means of key range locking.
* "Very few database implementation teams find hash indexes among the opportunities or features with a high ratio of benefit and effort, in particular if B-tree indexes are required in any case in order to support range queries and ordered scans."
--
1: https://www.postgresql.org/docs/current/indexes-types.html#I...
2: https://w6113.github.io/files/papers/btreesurvey-graefe.pdf
Tha was never the case. It would be silly to assume that given ultimately your GET and UPDATE operations are inter-process requests which involve serialization/deserializarion, and most of the time even require at least a network call.
O(1) doesn't mean "instant" it means "does not grow with the dataset"
the entire point of design time is to understand and design your data first.
What's hard to understand? You design a data store to store data, and aggregate data is still data. Do you care about low-level details of an aggregate data type? Do you care about how a UUID is implemented, or even if you store it as a string, a 128 bit integer, or a bitmap? Do you care if you store the UUID type along with the UUID?
Or do you simply want to store an ID that's produced/consumed by a client?
Now, replace UUID with JSON and you arrive at the same conclusion.
i care about how data is stored. There are limits to every data type and time spent on that in the beginning is time gained down the road
https://sqlite.org/draft/jsonb.html
Therefore, even if you had any remotely relevant reason for that fundamentalism, storing JSON documents in SQLite does more to meet that personal arbitrary goal than storing it in tabular form.
It’s so comfortable to iterate quickly without schema constraints
I tend to nuke my entire db, recreate it and reload some data into it. I wish there was a tool that ran in watch mode and patched the db based schema edits.
I'd be very careful about this simplistic reasoning. The whole point of schemas is data validation, and the hard part of "iterating quickly" is migrating data in a way you ensure it remains valid.
Neither of these requirements are tied to relational databases.
At most, breaking a schema ensures you cannot proceed with broken data without undergoing a migration, or completely wiping your database. But you are already doing that, aren't you?