4 ms·
> "However, the authors argue that KV doesn’t suit all problem domains. Mapping table-like data into a KV model leads to poor developer experience and (de)seria
by jppope 2y ago
> "However, the authors argue that KV doesn’t suit all problem domains. Mapping table-like data into a KV model leads to poor developer experience and (de)serialization costs. SQL would be much better, and SQLite being embedded solves this—it can be directly embedded in the serverless runtime."
The levels people will go to to so that they can use SQL never ceases to astound me.
- IshKebab 2y ago> Mapping table-like data into a KV model leads to poor developer experience This is definitely true in my experience. Unless you are literally storing a hashmap, KV databases are a pain to use directly. I think they're meant to be building blocks for other databases.
- liontwist 2y agoRelations are one of the most efficient and flexible ways to represent arbitrary graphs. In my experience Everyone goes to incredible lengths to avoid sql, in ignorance of this fact. They store (key, value) tables they they then extract into an object graph.
- LudwigNagasena 2y agoRelations are cool, but SQL DBs either prohibit or make it hard to present relations inside relations, which is one of the most common ways of structuring data in everyday programming life. You can see people suggesting writing SQL functions that convert rows to json or using ORM simply to query a one-to-many relationship, that's crazy: https://stackoverflow.com/questions/54601529/efficiently-mapping-one-to-many-many-to-many-database-to-struct-in-golang https://stackoverflow.com/questions/54601529/efficiently-map...
- bawolff 2y agoAny tool can be used incorrectly... Im not sure what relations in relations mean. Do you just mean M:N?
- LudwigNagasena 2y agoI mean 'tables' inside 'tables', 0NF. If I have a list of restaurants with their reviews, naturally, I have a table of restaurants, each of which contains a table of reviews. If I have a table of nested comments, naturally, I have a table of comments, each of which recursively contains a table of child comments. Those are some of the most common use cases for data presentation; and SQL-based DBs are not flexible enough to handle them in a straightforward way.
- liontwist 2y agoNo. This is binding your data structure to a single access pattern. You can get all the reviews for a restaurant. Now what if you want all the reviews left by a particular user? I invite you to read the original relational database paper which addresses this exact use case: A Relational Model of Data for Large Shared Data Banks
- LudwigNagasena 2y agoStoring such data structure would be binding to a single access pattern, I agree. But a query to retrieve such structure is simply convoluted for no reason to the point of many people resorting to hacks like json_agg.
- liontwist 2y agoMake a SQL view for the tree and a function in the client application which can read a tree in its linear projected form.
- LudwigNagasena 2y agoIf SQL were flexible, I wouldn’t need to create a whole view for a single query.
- liontwist 2y ago
- toast0 2y agoI mean, if SQL is a good match for the data, embedding a database engine designed to be embedded doesn't seem like too far of a reach?
- bawolff 2y agoTrying to put relational data into K-V store is always going to be a crazy mess. Even if the language used was not SQL, it would still obviously be a good idea to use the right type of database for your problem space.
- aidenn0 2y agoSQLite is smaller than many KV store libraries to begin with, and KV is a degenerate case of relational data.