108 points · by todsacerdoti · 5y ago · 62 comments
That's not enough to justify 'Oh I guess SQL vs NoSQL isn't about relational vs non-relational anymore'. It is 100% about relational vs non-relational. That SQL databases now support JSON is besides the point: nobody is saying to model your data as JSON documents just because SQL databases now support JSON. Similarly I don't believe that MongoDB is saying to model your data in a normalized relational fashion just because it supports 'pseudo joins' (are they even efficient?). The relational model is powerful because it stores data in a query agnostic way, and NoSQL databases are very much not that. If they were, they'd be SQL databases.
* yes, relational database != SQL. But SQL is the only widely used implementation for relation modelling, for better or worse. Show me a NoSQL databases that is built on relational modelling.
My prediction is that the next fad in database land will be normalized NoSQL. We can call it NoNoSQL.
e: Better idea. No2SQL.
Normalization is a logical process, part of database design. It’s not a by-product of a schema or design pattern, nor is it an implementation detail.
OO is ultimately based on pointers, even when hidden as inheritance, or called something else (references, composition). That form of organizing data is not relational pretty much by definition. You can’t” just do that [normalization] with OO patterns.” I’m not even sure what that means.
In DynamoDB you can use a single table model [1] to construct collections, which are similar to joins. The partition key is like a foreign key in an RDBMS. The sort key is like a combination of the normalized table identifier and primary key.
All of this can be as transparent to the business logic as it is in an RDBMS.
[1]: https://www.alexdebrie.com/posts/dynamodb-single-table/
I think it's obvious why this particular use (or misuse) of relational databases fails to scale, or gets hard to manage across multiple clients of the database possibly written in different programming languages. I have seen the same consistency guarantees implemented in Java and Python application code when the RDBMS could be doing that, and then hearing "SQL databases" blamed for the inconsistencies and scaling problems.
1. They store data as tables 2. The result of any query is also a table
THEREFORE you can apply queries to results of queries as long as you want to. You can compose queries out of smaller queries which makes them easier to reuse and understand. They are like LEGOs.
That's not a pedantic distinction; RDBs are a specific concept, and discussion in this area is rife with confusion about what is/isn't "relational", so it pays to use specific words.
I'd also argue that a critical feature of many relational databases (in practice; not inherently related to the relational model but facilitated by many implementations of it) is transactional guarantees and otherwise predictable management of concurrent data access.
That is true but I think the main significance is not that you can "request operations ... declaratively" but that the results of those operations have the SAME FORM as the thing/relation/table they were performed on.
That is what makes relational algebra as a concept so powerful. It is like numbers. You can perform operations on numbers and you get ... numbers. You can perform operations on tables (a.k.a "relations") and you get ... tables.
This argument is getting a lot of are time in this thread. It might be worth considering that if you're arguing words have specific meanings...they no longer do. Databases are technology with decades of historical effort. Any specific terms you come up with will grow fuzzy as new entrants stretch and strain old ideas.
Some terms have a more precise definition than others. I think "relational model" has a very specific meaning, apart from products that claim to implement it or not.
https://en.wikipedia.org/wiki/Relational_model#:~:text=The%2....
> if you're arguing words have specific meanings...they no longer do.
More on that: Recently Zoom the company was fined 85 million because it used the term "End-to-End encryption" inappropriately in its marketing materials. They could have tried to defend themselves by saying "The word end-to-end-encryption" no longer has a specific meaning, therefore we can use it to mean anything we want".
But obviously that would not have worked I don't think.
https://arstechnica.com/tech-policy/2021/08/zoom-to-pay-85m-...
If composition of queries is all you want, you can get it from way more things than just relational databases.
So relational means every operation produces a result to which all the same great set-theoretic database-operations are applicable. That is why it is a great basis for databases.
That along with denormalization is how I’ve always thought about it. I learned SQL first and I’ve always seen the queries as just different ways of expressing “give me all of the documents where x is true”.
To me, Mongo is just the one where you can accidentally have different schemas in the same table (collection), you can have lists and embedded documents in a document, and the data is already JSON. Make your data as relational or nonrelational (or both) as you want.
I want a decent query language and I don't believe the hype about performance with NoSQL.
I certainly don't want to manage schema in code.
I was hoping the NoSQL thing would die a bit like XML. Perhaps it needs more time.
They might be converging if you use non-relational to mean something pretty specifc (like "MongoDB and PostgreSQL JSON"). But unless we want to coin another term that means something else than the natural english meaning, it's problematic.
There are lots of databases that are not relational, but still have schema and structure in non table centric ways, like schemaful graph databases, object databases and things like Datomic and triple stores.
from: https://en.wikipedia.org/wiki/Relational_algebra#Implementat...
I remember how this suprised me a lot after thinking that SQL and SQL databases are based on relations, thinking "how can two equal rows co-exist in a relation". SQL needs things like "hidden identifiers / row keys" and so on to be squeezed into being "relational".
I believe it would also add complexity on net for users, as they would have to re-introduce those "hidden identifiers / row keys" in the not-uncommon cases where bag semantics are desired.
From a practical perspective, SQL is much more idiomatic than mongoDB's confusing query "language." But, cards on the table, almost every single new project I start up, I start with MongoDB :)
Having a dynamic schema implies that you get no guarantees from the database, so the application has to discover and validate the schema at runtime to be able to do useful things.
I like data integrity so I prefer static schemas, but sometimes it can be useful to have a component in your tables where you do the extra work of dynamic inspection or just transport it as an opaque blob.
There are other parts of the process to determine where a new property fits for me( for example it might actually need an entire state store if its own), but in general this is where I begin.
Data is usually relational, there's no getting away from that just because of the database you use. NoSQL can manage all kinds of relations, just with an extremely different approach.
If you're interested in learning how this works instead of repeating the tired meme of "mongodb lol" checkout Alex Debrie's book on DynamoDB and Rick Houlihans YouTube content.
I also wrote a brief thread about this on Twitter: https://twitter.com/thdxr/status/1394903426023272452?s=19
NoSQL can model relational data, but it is not a relational model (as understood by E.F. Codd).
Also, NoSQL data access patterns are pretty much set in stone, which is kind of what the relational model explicitly avoids.
Yeah, that's pretty much how I translated that whole NoSQL thing. As far as I'm concerned, when the industry uses SQL, I assume they mean relational with schemas.
IIRC the open source YottaDB also has a SQL access mode, in addition to MUMPS.