## glossary
What is NoSQL?
NoSQL designates a family of databases that do not follow the relational model of tables, rows and joins. The acronym is usually read as "Not Only SQL", since many of them offer their own query languages and some even support SQL.
They emerged in the 2000s out of the concrete needs of companies like Google and Amazon: distributing data across hundreds of servers, accepting schemas that change frequently and prioritizing availability over immediate consistency.
The four main types
- Document — stores nested JSON records. MongoDB, CouchDB. Good for data with variable structure.
- Key-value — the simplest model: a key points to a value. Redis, DynamoDB. Excellent for caching and sessions.
- Column-oriented — organizes by columns instead of rows. Cassandra, HBase. Scales massive writes and time series.
- Graph — models entities and relationships as first-class citizens. Neo4j. Ideal for social networks and fraud detection.
Relational versus document in practice
-- RELATIONAL: normalized, joins at read time
SELECT p.nome, e.rua, e.cidade
FROM pedidos p
JOIN enderecos e ON e.id = p.endereco_id
WHERE p.id = 42;
// DOCUMENT: denormalized, everything together
{
"_id": 42,
"nome": "Ana Souza",
"endereco": {
"rua": "Rua das Palmeiras, 120",
"cidade": "Juiz de Fora",
"uf": "MG"
},
"itens": [{ "sku": "A-19", "qtd": 2, "preco": 4990 }]
}The difference in philosophy shows right there. The relational model avoids duplication and resolves relationships at read time. The document model accepts duplicating data so that a single query brings everything at once — faster to read, more work to keep consistent when something changes.
The CAP theorem and what it implies
In a distributed system, it is impossible to simultaneously guarantee consistency, availability and partition tolerance. Since network partitions do happen, the real choice is between consistency and availability. Relational databases traditionally prioritize consistency; many NoSQL databases choose availability, accepting eventual consistency — the data converges, just not instantly.
When to choose each one
Use relational when the data has a stable structure, relationships matter and transactions need to be atomic — the case of financial systems and most business applications. Use NoSQL when the schema varies a lot, horizontal scale is required or the access pattern is known and specific. To get hands-on, see how to integrate MongoDB with Next.js and, on the relational side, MySQL and its applications.
## faq
Frequently asked questions
Is NoSQL faster than SQL?
Not in general. It is faster for the access patterns it was modeled for, especially simple reads by key and distributed writes. For analytical queries with multiple joins and aggregations, relational databases are usually superior.
Does NoSQL have no schema?
It does, it is just not enforced by the database. The schema comes to exist implicitly in the application code. That gives flexibility and transfers responsibility: without validation in the database, inconsistent documents silently accumulate until something breaks.
Can I use NoSQL and SQL in the same project?
Yes, and it is common — the practice is called polyglot persistence. A typical example is PostgreSQL for transactional data, Redis for caching and sessions, and Elasticsearch for full-text search. The cost is the operational complexity of running several systems.