A relational DBMS stores data in tables. Each table has a fixed set of columns with declared types, and each row is one record. Rows do not have to arrive in any order, and they share only the columns the table declares.
The link between two tables is a foreign key. The child column points at a primary key in the parent table, and the engine refuses any insert that points at a row that does not exist. That rule lives in the schema, not in the application code, so it holds no matter which program writes the data.
The join in the last query brings the two tables together. It pairs each order with the customer that placed it, so you get the name and the city next to the amount without storing them twice.
That is the shape of a relational design. Each fact lives in one place, tables are joined to answer a question, and the constraints in the schema keep the data honest.
The useful way to sort them is by the shape of the data and the kind of question you ask about it.
A relational DBMS stores data in tables with a fixed set of columns and declared types. It is the right choice when your data has relationships, when you want the database to stop you storing nonsense, and when several parts of your application need to see the same facts consistently.
A document store keeps each record as a self contained document, usually JSON. Records may have different shapes, and you read a whole document or one path inside it. It suits catalogs, event payloads and content where every item carries its own fields.
A key-value store is the simplest of the family. You put a value under a key and get it back. It is fast, and it fits caches, sessions and configuration.
A wide-column store groups rows by partition key and lets each group carry its own columns. It suits very large volumes of event or time series data that are written often and read by key range.
A graph store keeps nodes and edges as the primary structure. It suits recommendation, fraud and network questions where the path between two things is the answer.
Choosing one comes down to the shape of your queries and how much consistency you need. Most systems end up with a relational core and a specialised store beside it.
You keep each document as JSON text in a column and query it with the JSON functions that modern relational engines ship with. SQLite has had json_extract and json_each since version 3.9, and PostgreSQL, MySQL and SQL Server all have equivalents.
Two shapes of query matter. The first reads one field out of every document, which behaves much like a column read in a normal table. The second expands an array inside the document into one row per element, and that gives you the join that a document store would do in the application layer.
The cost is that the database no longer enforces the shape of the data. Nothing stops one document from missing a field that another has, so you have to validate it yourself, usually when the document is written.
Indexing needs care as well. A normal index on the text column only matches the whole document, so a query that filters on one field cannot use it. You need an expression index on the extracted value, and every field you want to filter on needs its own index. That index is fixed, while a native document store lets you index any field you like.
So when is this a good trade? It is good when documents are always read as a whole, when the collection is small, and when one transaction has to cover the document and the rows around it. A document store is better when the fields vary a lot, when you index many different fields, or when writes to one document are far more frequent than reads across the collection.