News for hackers. Stuff that matters.
Re:Why NoSQL by invalidname on Tuesday October 05, 2021 @10:32PM (#28768493)
NoSQL are super easy to start with. Then you have a pile of heaping unstructured data that's hard to query, hard to report and gain insight on.

Every data task becomes a programming problem which needs a team to work on to get something that might be stale. With SQL there's a lot of work. But you have a DB that everyone knows. 3rd party tools work. Developer on-boarding is easy. Your boss asks you how many users used feature X in the past month you can actually tell him right away...

Performance is actually good and consistent. Your data is also consistent and respects acid principles. The whole write performance of NoSQL DBs is a bit of a crock that doesn't stand the test of scaling. With proper cashing SQL is as performant when done right and the profiling tools are better. Screw no-SQL. They are just Object Oriented DBs (which were a disaster in the 90s) in new clothes.

Re:Why NoSQL by tharkun__ on Tuesday October 05, 2021 @10:38PM (#28768541)
Actually they're even older.

When I talked to my dad about RDBMS he was like "weeeelll, sure, there's things like DB2 UDB that do relational but performance wise, nothing beats reading the data straight by key in exactly the format you need.".

DB2 UDB: "Initial release: 1987; 34 years ago". I.e. what he would rather use and is sort of the NoSQL equivalent is _even older than that_.

Background: he started off with 360 assembler and worked all his working life on IBM Mainframes and the various technologies in and around it. They had it all and they had it before it came to "us". We're just re-inventing most of these things on much cheaper and more open hardware and software.

Re:Why NoSQL by dd444fgdfg on Tuesday October 05, 2021 @11:09PM (#28768718)
what I fail to fathom today is, when I think back to the late 90s, I had various production rdms, SQL Server 6 (or 7, can't remember), running on something like a Pentium 4, with millions of rows of data in various tables... and the performance was... fine. not an issue.
Re:Why NoSQL by jjav on Wednesday October 06, 2021 @03:23AM (#28770176)
Today you need a Cassandra cluster fronted by a Kubernetes cluster to get similar performance. The good news is that you don't need a couple boxes under your desk, you can pay AWS tens of thousands a month for it.
Re:Why NoSQL by foota on Tuesday October 05, 2021 @11:22PM (#28768801)
Single machine postgres is mostly fine when you're working with less than hundreds of million of rows, less than a few hundred gigs of data, don't need HA, and don't need more than a few thousand QPS. Outside of those constraints is why new things exist imo.
Re:Why NoSQL by crooked-v on Tuesday October 05, 2021 @11:46PM (#28768956)
Of course, the overwhelming majority of all businesses (including web-centric businesses) work fine within those constraints.
Re:Why NoSQL by foota on Tuesday October 05, 2021 @11:55PM (#28769016)
Sure, small businesses are fine using postgres. I would argue that by developer market share though most (or perhaps just many) developers have to worry about these issues, since the companies that have scale have to higher many more developers.

There's also the argument that businesses hoping to scale might be better off assuming they will need it to save themselves work down the road.

Re:Why NoSQL by jmchuster on Wednesday October 06, 2021 @01:38AM (#28769577)
Computers are very fast and fast storage is very cheap these days.

Your Data Isn't That Big https://www.chrisstucchio.com/blog/2013/hadoop_hatred.html

Re:Why NoSQL by jjav on Wednesday October 06, 2021 @03:31AM (#28770226)
> Your Data Isn't That Big

This is an extremely important lesson. You don't have Big Data, unless you're one of a handful of huge companies.

Years ago I joined a mid-size public company and inherited one particular service. Management was adamant that it had to migrate away from MySQL onto Cassandra due to data volume. But there were no metrics being tracked, it was driven by "we have to do it because everyone is doing it".

I started tracking actual usage, growth and performance and it didn't seem to point to a problem that needed solving. So I halted that project (to their credit, they listened to engineering input so I was able to).

A few years later when I left, it was still perfectly fine on MySQL. Nowhere close to running out of capacity. Today it's been almost ten years and while I'm not there, what I hear is that it's still fine.

Re:Why NoSQL by foota on Wednesday October 06, 2021 @04:01AM (#28770405)
"But my data is more than 5TB! Your life now sucks - you are stuck with Hadoop. You don't have many other choices (big servers with many hard drives might still be in play), and most of your other choices are considerably more expensive."

My point is that large companies that do need to scale hire many developers. FAANG likely hire north of several hundred thousand engineers alone, and according to this article[1] there are only something like 1.5 million software engineers in the US.

[1]: https://www.daxx.com/blog/development-trends/number-software...

Re:Why NoSQL by tomnipotent on Wednesday October 06, 2021 @03:55PM (#28777602)
Even combined, FAANG is probably only around 150k programmers. A vast majority of the worlds 24-26M working software programmers do not work at them, or even at the top 100 such companies.
Re:Why NoSQL by jeltz on Wednesday October 06, 2021 @06:00AM (#28771137)
PostgreSQL handles 100k QPS without any issues unless your queries are very complex and I know many people who run multi-TB databases in PostgreSQL without any issues either. But it all depends on your workload of course.
Re:Why NoSQL by foota on Wednesday October 06, 2021 @03:45PM (#28777467)
Yeah, I probably could have bumped both those numbers an order of magnitude.
Re:Why NoSQL by dikei on Wednesday October 06, 2021 @07:06AM (#28771620)
Well, millions of rows of data is tiny these days: if you have 100_000 IOT devices, each generate on average 10 telemetry points a second, that's already 1M writes per second. Storing these telemetry for a week and you already have 600 billions rows.

Of course that's a oversimplification, but the data generated today is mind-boggling large compared to the 90s.

Re:Why NoSQL by nine_k on Wednesday October 06, 2021 @07:31AM (#28771802)
If you have 1M writes per second, you have a data collection problem, no matter the technology. Doing it on a single node is not a great idea just because it'd be a huge SPOF.

In most cases, you have colossally fewer than 1M writes per second, and you usually distribute them over several boxes. the IoT avalanche of writes in particular is naturally sharded, that is, all these writes can occur independently, and then you can replicate statistics into an analytical RDBMS.

It's a large write load that needs to be transactionally ordered, like a stream of purchases in a large online store, that can be a hard(er) problem for an RDBMS.

Re:Why NoSQL by dikei on Wednesday October 06, 2021 @08:57AM (#28772570)
Yup, I agree with you. Most businesses can work fine with traditional RDBMS, even on TB scale if you have a large box with lots of RAM and SSDs.

My example was just one use-case where one should consider using a more unconventional DBs like Cassandra or HBase.

Re:Why NoSQL by da39a3ee on Wednesday October 06, 2021 @07:13AM (#28771671)
> but the data generated today is mind-boggling large compared to the 90s.

For what percentage of companies would you say your statement is true?

Re:Why NoSQL by smallerfish on Wednesday October 06, 2021 @09:25AM (#28772872)
:s/these days/at your particular job/g
Re:Why NoSQL by jeltz on Wednesday October 06, 2021 @06:02AM (#28771151)
It is not and issue today either. Modern RDBMs have become better optimized and hardware has become faster so a lot of NoSQL is premature optimization where people optimize for having 100+ TB databases when their database actually is 100 GB.
Re:Why NoSQL by tootie on Tuesday October 05, 2021 @11:44PM (#28768941)
The original Unix DBM file was basically NoSQL in a SQLite type package and it was developed in 1979.

https://en.wikipedia.org/wiki/DBM_(computing)

Re:Why NoSQL by xarope on Tuesday October 05, 2021 @11:04PM (#28768692)
I worked on DB2 UDB in the 90s, and learnt a lot about DBs through all the improvements in isolation levels. Those were the days when you'd actually have to make some judgement calls about setting specific isolation levels to improve performance. Nowadays you just chuck an SSD and several TBs of memory into the works (or talk to someone about some massively horizontally scaled solution, and distract from the real problem at hand).
Re:Why NoSQL by Clubber on Tuesday October 05, 2021 @11:25PM (#28768819)
Oracle introduced RDBMS in 1979 based off Codd's paper in 1969. Mainframes were all flat file not object-relational, but you could finagle them to be sort of that. Object-Relational didn't come into play until the 90s.

The main issue with object relational as the "main" database is its hard to run reports on. Reports (for biz) is half the reason the system exists. I'm not saying ORDBMS don't have a place, but RDBMS is much better suited for real-time data analysis / reports. I think ORDBMS is popular because it's easy for non-database people (who don't know 3rd normal form or SQL) to store stuff in.

Re:Why NoSQL by inopinatus on Tuesday October 05, 2021 @11:42PM (#28768929)
Let's not erase the work of Stonebraker et al whose efforts through the 70s were a lot closer to Codd than Oracle's. Ingres's query language, Quel, springs to mind: being directly based on the relational calculus it was far more readily composable than SQL (which might be charitably described as "borrowing ideas from the relational model") was or is.
Re:Why NoSQL by throwaway81523 on Friday October 08, 2021 @03:11AM (#28796530)
You may be overlooking System R from 1974:

https://en.wikipedia.org/wiki/IBM_System_R

Re:Why NoSQL by eru on Tuesday October 05, 2021 @11:28PM (#28768846)
Well, even plain old filesystems are some weird hybrid between key-value stores and graph data bases, too.
Re:Why NoSQL by inopinatus on Tuesday October 05, 2021 @11:31PM (#28768864)
it's sometimes very helpful to think of filesystems as a streamable blob store with a hierarchical key
Re:Why NoSQL by eru on Wednesday October 06, 2021 @02:00AM (#28769697)
That's one valid perspective. But don't forget that you can also seek and mmap etc. And hard-links are a thing, too.

Things like fuse also show that it's easy to view other databases as filesystems, too. As a silly example, you can 'explode' /etc/passwd into individual files per entry. Or you could expose even a relational database as a filesystem.

For the latter, you could do something simple and expose tables as directories and rows as files. Or you could do something dynamic, and eg represent (read-only or idempotent) queries as file-names, and their results as file contents.

That wouldn't be so much a traditional filesystem, but would be accessible via a filesystem interface.

Re:Why NoSQL by tharkun__ on Wednesday October 06, 2021 @12:45PM (#28775244)
I hear AWS DynamoDB is basically just a "key value store interface" to S3 file storage.
Re:Why NoSQL by omegalulw on Wednesday October 06, 2021 @01:28AM (#28769530)
This is not the right way to approach this. NoSQL and SQL both have use cases they are suited for, and saying one is better than the other is wrong. Faster writes of NoSQL does help with scaling - but if your app needs transactions than obviously NoSQL won't work.

For reporting, unstructured data is actually not bad. If your report requires you to scan your whole database, then SQL won't necessarily be faster, you have to think about disk performance as well as how complex of a join(s) do you need.

Re:Why NoSQL by kaba0 on Wednesday October 06, 2021 @09:36AM (#28772991)
SQL databases can do several levels of transaction “strictness”, so their write speed can be just as fast.
Re:Why NoSQL by felipeccastro on Tuesday October 05, 2021 @11:02PM (#28768680)
I use Rails and Mongo at work. There is a schema, enforced declaratively at the application layer (mongoid). With Rails Console querying the database ad hoc is even easier than with SQL, thanks to mongoid api and Ruby’s expressiveness. There are no transactions, but single document writes are atomic. Performance is pretty good; the one hardship I run into is that the mongoid api is so high level that you don’t see when you’re firing way too many queries at the dB (but that’s an ODM issue, not mongo’s, other ODMs might not do that).
Re:Why NoSQL by erik_seaberg on Wednesday October 06, 2021 @12:16AM (#28769131)
> schema, enforced declaratively at the application layer

Nobody has just one app forever. Any org that gets big enough is going to be uncertain about how many apps depend on a particular database, much less whether they’re all in the same language and bundle the same schema rules. Customer service builds weird support tools, accounting and compliance build weird reports …

Re:Why NoSQL by lmm on Wednesday October 06, 2021 @01:01AM (#28769378)
Make sure each datastore has a clear owner, and access it via that API rather than directly. If you really must share a datastore, use a schema registry. Sharing between multiple applications doesn't really work for SQL database either (e.g. if you have multiple applications writing to your database in transactions then you're virtually guaranteed to get deadlocks).
Re:Why NoSQL by irishsultan on Wednesday October 06, 2021 @06:41AM (#28771439)
> (e.g. if you have multiple applications writing to your database in transactions then you're virtually guaranteed to get deadlocks).

That assumption is only true if the DB is continually used by different applications. The reality is more likely a large number of applications used by a relatively small set of users, so most of the time there won't be any application writing, and it would be extremely rare for multiple applications to write at the same time.

Re:Why NoSQL by smorgusofborg on Wednesday October 06, 2021 @10:32AM (#28773628)
Are rare deadlocks better than frequent ones? That sounds like a good way to not know you have problems.
Re:Why NoSQL by tdrdt on Wednesday October 06, 2021 @04:27AM (#28770553)
This only works in theory.

In reality sometimes access via an API is way too slow or is lacking flexibility.

And I don't get this: "(e.g. if you have multiple applications writing to your database in transactions then you're virtually guaranteed to get deadlocks)"

Isn't this why transactions exist in the first place?

Re:Why NoSQL by belk on Wednesday October 06, 2021 @06:21AM (#28771289)
depends on what level of isolation and how it's done, MVCC avoids deadlocks, but if you manually lock any row/table, you can still run into deadlocks. but the DBMS' transaction manager will notice and timeout one of the transactions, failing it.

While MVCC avoids deadlocks, you'll still get a lot of failed transactions if they all operate on the same data at the same time, which you'll have to retry, but I'll take that over data inconsistency

Re:Why NoSQL by nine_k on Wednesday October 06, 2021 @07:51AM (#28771970)
Quite often you have several applications that look up each other's data, but mostly write to their own tables.

(But indeed, with uncoordinated development, deadlocks can occur. Still better than data corruption.)

Re:Why NoSQL by foota on Tuesday October 05, 2021 @11:16PM (#28768768)
I feel like the issue with nosql is that it's largely unnecessary when newsql databases exist.
Re:Why NoSQL by nine_k on Wednesday October 06, 2021 @07:48AM (#28771938)
This may continue to work, as long as performance is not your primary consideration (you have little data and few queries), you don't have to evolve the schema much, and no programming errors or ad-hoc updates introduce data that fail to follow the schema at the DB level.

So, it might be adequate for a small and carefully maintained project, likely like many alternatives.

Or do you use a high-load, distributed, replicated / sharded Mongo configuration? Then I'd gladly listen to more details.

Re:Why NoSQL by YZF on Wednesday October 06, 2021 @12:13AM (#28769116)
What's your SQL db of choice where you can scale it up seamlessly beyond a single instance?

EDIT: to add ... and with HA/DR and where you keep all the good guarantees, queries etc.?

Re:Why NoSQL by belk on Wednesday October 06, 2021 @06:43AM (#28771455)
CockroachDB, I heard the dev experience of spinning up nodes can be dumbed down to 1 or 2 docker commands, and it's Postgres compatible, continues to have global transactions, although you wont get the same transaction performance as something GPS/clock hardware synced like Spanner, it's still a good self hosted solution.

If you're interested, CRDB writes a lot about how they do their transactions on their blog, it's good to know what guarantees you actually get with your DB's transactions.

Re:Why NoSQL by nine_k on Wednesday October 06, 2021 @08:03AM (#28772075)
For what reason do you need to scale it beyond a single instance?

If all you need is to alleviate the high read load (many selects), nearly every SQL database (even SQLite!) has a free and supported way to create read replicas, usually out of the box.

If you need distributed transactional updates, MySQL / MariaDB has Galera (GPL), and Postgres has Citus (proprietary with a few AGPL parts).

And, of course, there is CockroachDB that prioritizes reliability over speed, but is truly distributed out of the box.

Re:Why NoSQL by YZF on Wednesday October 06, 2021 @09:18PM (#28780598)
Right now I (well, we, my team) uses Hbase and in a previous project I used Cassandra. These are very high scale systems where we need replicated writes (for durability and availability), we need horizontal scalability and performance (write heavy or mixed read/write workloads) trumps transactionality. There aren't a lot of writeups about performance benchmarks between NoSQL and SQL but as far as I know it's not even close to the same ballpark: https://www.scylladb.com/2021/01/21/cockroachdb-vs-scylla-be...

With something like Cassandra you get read after write guarantees that I think you don't get with read replicas and SQL databases but I'm not too familiar with the latest there. Also once you start breaking up your SQL databases into shards you lose all SQL goodness across shards (like joins and other properties).

So no free lunches basically. I'd love for there to be something fast, scalable, queryable, transactional etc. etc. Honestly I haven't looked in a while but every open source SQL solution I've seen in the past that claimed to be durable/reliable/scalable doesn't actually do that under failure modes like NoSQL does and pretty much loses either performance or other guarantees or both. Ofcourse NoSQL doesn't solve some of these problems, but at least you know what you're getting into ;)

Re:Why NoSQL by nine_k on Wednesday October 06, 2021 @10:51PM (#28781266)
I agree! I've seen Cassandra in production, and learned why it was put there. With it, you still get some of the SQL goodness, but most guarantees are only within one shard.

With that, you let go of the global ordering, because global ordering / single-point serialization just becomes technically infeasible. At that point you usually don't exactly need them, though. You only need local order within a transaction.

Re:Why NoSQL by qaq on Wednesday October 06, 2021 @01:36AM (#28769569)
Seeing most people go for the cloud what percentage of projects will outgrow say Aurora? and beyond Aurora there is a ton of options like CockroachDB, TiDB, Yugobyte etc.
Re:Why NoSQL by FridgeSeal on Wednesday October 06, 2021 @12:40AM (#28769270)
If the data couldn’t be fully sharded (I.e. independent db’s and replicas), I’d personally choose Cockroach DB for this, I admittedly haven’t had the pleasure of using Cockroach, but I’ve seen alternative approaches and knowing what I wouldn’t do again…
Re:Why NoSQL by pjmlp on Wednesday October 06, 2021 @04:38AM (#28770614)
No love left for POET? :)
Re:Why NoSQL by lmm on Wednesday October 06, 2021 @12:59AM (#28769368)
> But you have a DB that everyone knows. 3rd party tools work. Developer on-boarding is easy.

Not reliably. All the different DBs have subtle misbehaviours and mismatches with the tools.

> Performance is actually good and consistent.

Lol no. Indexed joins and unindexed joins look exactly the same but have vastly different performance characteristics. And even if you have a query that currently performs well, you never know when or why the query planner will change its mind.

> Your data is also consistent and respects acid principles.

Only because you drop data on the floor if it's inconsistent, which is rarely a good enough solution in the real world. E.g. someone tries to add a customer but the city has been deleted in the meantime -> they get an error, and the system throws away everything they input about the new customer. You end up having to implement your own dead letter queues etc. and do all the work you would with a NoSQL datastore.

> With proper cashing SQL is as performant when done right and the profiling tools are better.

Caching makes your performance even more arbitrary and incomprehensible - it works great right until it doesn't. Profiling is great but it's a poor substitute for being able to reason about what the performance of your queries will be.

> Screw no-SQL. They are just Object Oriented DBs (which were a disaster in the 90s) in new clothes.

On the contrary - the problems with SQL databases are much the same as the problems with object databases.

Re:Why NoSQL by marcos100 on Wednesday October 06, 2021 @10:12AM (#28773414)
If you're throwing everything the customer have input then you have a poor written application.

Not inserting bad data is much better than trying to make sense of inconsistent data because you don't know what is true or not.

Re:Why NoSQL by lmm on Wednesday October 06, 2021 @09:27PM (#28780691)
Validating consumer input is good. Throwing it on the floor when it fails validation is bad. You want to separate "accept the consumer's input" from "validate it", which is something that's very hard to do in RDBMSes.
Re:Why NoSQL by EdwardDiego on Wednesday October 06, 2021 @01:32AM (#28769545)
> Only because you drop data on the floor if it's inconsistent, which is rarely a good enough solution in the real world. E.g. someone tries to add a customer but the city has been deleted in the meantime -> they get an error, and the system throws away everything they input about the new customer. You end up having to implement your own dead letter queues etc. and do all the work you would with a NoSQL datastore.

What. Who's letting people delete random shit out of the DB? Why is the origin of this data not validating against the actual data from the DB before sending data?

"Hey we have to ensure that customers are selecting valid cities.

We have a list of cities in the DB. Let's ensure we cache the cities in the api server so that we're not hitting the DB for every page load for data that will very rarely, if ever, change.

Especially since we revoked Dave's DELETE permissions after that last time he deleted stuff from a production database."

Re:Why NoSQL by lmm on Wednesday October 06, 2021 @02:23AM (#28769841)
> Why is the origin of this data not validating against the actual data from the DB before sending data?

It's on the client side, so it can't hold an open transaction with the server. It can validate against a previous version of the list of cities, but there's always the possibility of a delete happening in parallel.

(And if your answer is to use a delete flag rather than actually deleting a row, then you're undermining the referential integrity constraints that were supposed to be the whole point of using a relational database)

Re:Why NoSQL by EdwardDiego on Wednesday October 06, 2021 @03:07AM (#28770086)
>It can validate against a previous version of the list of cities, but there's always the possibility of a delete happening in parallel.

If a "city" is a) required attribute of an entity and b) required to exist as an entity itself, then deleting a city would require deleting all other entities that refer to that city.

If city is a nullable attribute, then your validation issue you raised earlier is voided - an invalid "city" can just be replaced with null.

Assuming you're wanting to delete cities, then your client side shouldn't be firing off data and assuming success.

> It can validate against a previous version of the list of cities, but there's always the possibility of a delete happening in parallel.

Yep, caching is hard, but your argument that "RDBMS aren't that great" is predicated on a very... ...convoluted system.

Re:Why NoSQL by lmm on Wednesday October 06, 2021 @03:51AM (#28770338)
> If a "city" is a) required attribute of an entity and b) required to exist as an entity itself, then deleting a city would require deleting all other entities that refer to that city.

Right, so usually what people implement (and what the database enforces by default) is that you can't delete a city if there are any customers in that city. But they don't think about what happens when two people try to make changes in parallel, because the whole point of ACID is that each query runs in its own transaction.

> Yep, caching is hard, but your argument that "RDBMS aren't that great" is predicated on a very... ...convoluted system.

All the use cases for referential integrity - and transactionality - are like this though. You can't actually use them for anything, not with a web app where the client can't hold a transaction open.

Re:Why NoSQL by kaba0 on Wednesday October 06, 2021 @09:44AM (#28773104)
> But they don't think about what happens when two people try to make changes in parallel, because the whole point of ACID is that each query runs in its own transaction.

You do know that the D in ACID stands for consistency? That is in case a transaction try to modify something that was already changed in a parallel transaction that was already committed, it will fail and will be rolled back (given proper transaction levels).

So I really don’t understand your point. Also, you can hold a transaction open for a client..

Re:Why NoSQL by lmm on Wednesday October 06, 2021 @08:10PM (#28780113)
> That is in case a transaction try to modify something that was already changed in a parallel transaction that was already committed, it will fail and will be rolled back (given proper transaction levels).

It will fail and be rolled back and you will lose the user's data that was written in it, unless you effectively build your own datastore on top of what the database offers.

> Also, you can hold a transaction open for a client..

For a client that's potentially gone offline for an indefinite period? Certainly not. Even if you're heartbeating that the client still has the form open somehow, that seems like a very suspect architecture.

Re:Why NoSQL by EdwardDiego on Wednesday October 06, 2021 @09:42PM (#28780792)
> It will fail and be rolled back and you will lose the user's data that was written in it,

The point of relational integrity is ensuring all your data is in a valid state. If you don't want to lose a client's data because you deleted a city, there are multiple engineering approaches open to you.

1) Don't delete cities, just don't. The semantics of doing so don't make any sense in the first instance.

2) Further, deleting entities from an RDBMS is pretty damn final. What if a business analyst wanted to do some historical analysis? Well, that city is gone now, so it won't be there. This is where "soft delete" comes in (And no, soft delete doesn't destroy referential integrity) - you've marked the entity as no longer valid for use, but you still retain your data surrounding it.

3) Don't respond with a 2xx until the data store acknowledges successful insertion.

4) Use Debezium or similar to broadcast entity changes to a Kafka topic keyed on entity id. If you want to retain all changes (e.g., for event streaming), then use an appropriate retention strategy. If you want to retain only the latest state, use log compaction - it will retain the latest record with a given key.

This makes it easy for an app being spun up to obtain the entity state without touching the DB, and by continuing to subscribe to the topic, update its cache to match the source of truth.

Of course, you don't have to use Kafka, it's just one approach, but many other systems will allow you to do the same.

Basically, your objections say nothing about the usefulness of a relational datastore, but rather, the need for careful engineering when building overly distributed systems.

And through all this, I'm wondering how you imagine a non-relational datastore solving these problems any better.

Re:Why NoSQL by lmm on Friday October 08, 2021 @03:28AM (#28796625)
> The point of relational integrity is ensuring all your data is in a valid state.

Right, and doing that at the lowest level of your datastore is a fundamentally misguided approach, because it means you can't ever store data that's in an invalid state (almost by definition). So when data does become invalid, you're effectively forced to destroy it.

> And no, soft delete doesn't destroy referential integrity

Yes it does. It destroys the property you described above - that you ensure all your data is in a valid state.

> Don't respond with a 2xx until the data store acknowledges successful insertion.

So the user sees an error. That doesn't actually help much, because what can they do with that error?

> Use Debezium or similar to broadcast entity changes to a Kafka topic keyed on entity id. If you want to retain all changes (e.g., for event streaming), then use an appropriate retention strategy. If you want to retain only the latest state, use log compaction - it will retain the latest record with a given key.

Yes, now keep tugging on the thread of that thought. If you try to write code to reconstruct the state of your relational database based on those changes, you've got two copies of your logic that will inevitably get out of sync, and you'll have bugs that you only discover when you try to actually do it. (And if you only record differences between writes that actually made it into the relational database, you haven't solved the original problem of data being lost because writes are rejected). What you want to do is instead make those Kafka events the primary "source of truth" and construct the "current state of the world" based on that, i.e. event sourcing.

You don't, and can't, make use of transactions with that approach - you get (eventual) consistency because each log is ordered, which gives you the properties that you want with less of the downsides (deadlocks), but writing and reading the eventual results of that write is a fundamentally async process (which is good in the long term - it forces you think about your dataflow and avoid loops - though it might involve more work upfront). And you don't really have relationality - if you need a relation in your live dataflow, you'll generally join at the event pipeline level and make the joined thing its own stream (much like a materialized view in SQL-land). You can build secondary indices etc. but those are explicitly a secondary thing layered on top of your primary datastore.

Re:Why NoSQL by kaba0 on Wednesday October 06, 2021 @08:39PM (#28780316)
What does the form have to do with anything? That’s just part of an application, nothing special. What about storing the results in memory until you can make sure it is successfully stored? Like, this has nothing to do with databases, that’s just application architecture. Also, what language/framework have you been using because these things are routinely handled by any that worth anything.
Re:Why NoSQL by lmm on Wednesday October 06, 2021 @09:34PM (#28780735)
> What does the form have to do with anything? That’s just part of an application, nothing special.

To be able to actually use database transactions you'd need them to extend across the form's lifetime. You can do that with a local application, but not with a webapp with the web request cycle.

> What about storing the results in memory until you can make sure it is successfully stored?

That has all the same problems as storing your data in memory and not using a datastore. In this scenario the data can never be stored because it now violates referential integrity.

> Also, what language/framework have you been using because these things are routinely handled by any that worth anything.

Many of the big-name Python or JVM-based ones, but it's a fundamental problem that can't be solved at that level. Which language/framework are you claiming handles this well?

Re:Why NoSQL by EdwardDiego on Wednesday October 06, 2021 @09:30PM (#28780708)
> All the use cases for referential integrity - and transactionality - are like this though. You can't actually use them for anything, not with a web app where the client can't hold a transaction open.

You should probably tell the millions of companies actually using them for things that they're wrong. I'm sure they'll feel very silly.

Re:Why NoSQL by lmm on Friday October 08, 2021 @02:45AM (#28796410)
The actual businesses generally don't. It's funny how RDBMS fans always say "businesses x, y and z were built on MySQL" and forget to mention that they were actually using MyISAM-based versions of MySQL that had no ACID and barely any referential integrity constraints. Most of the "mongodb is web scale" crowd is coming from the same ideology as the people who were hating on MySQL 10 years ago.