Skip to main content

NoSQL

Not Only SQL

Pronunciation
noh-ES-kyoo-EL or noh-SEE-kwul
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/nosql

In short

NoSQL is a family of databases that store data in models other than relational tables, such as documents, key-value pairs, wide columns, or graphs.

What is NoSQL?

NoSQL is an umbrella term for databases that do not use the traditional relational model of tables linked by keys. The name is usually read as 'not only SQL', because many of these databases still offer query languages, and some even support SQL-like syntax.

There are four main types. Document databases such as MongoDB store JSON-like documents; key-value stores such as Redis map each key to a value, like a giant dictionary; wide-column stores such as Apache Cassandra organize data into flexible columns spread across many machines; and graph databases such as Neo4j store nodes and the relationships between them.

NoSQL databases became popular for large web applications because many of them are designed to scale horizontally, meaning they spread data across many servers, and they often allow a flexible schema, so records in the same collection can have different fields. They are common for caching, user sessions, real-time analytics, product catalogs, and social networks.

SQL versus NoSQL is a trade-off, not a contest. Relational databases enforce a strict schema and excel at complex queries and multi-row transactions, while NoSQL databases trade some of those strengths for flexibility, scale, or speed in specific access patterns. Today the line is blurrier: many NoSQL databases support transactions, and relational databases like PostgreSQL can store and query JSON.

At a glance

The same customer and her orders stored two ways: in a relational database as rows in a users table and an orders table linked by user_id, and in a document database as one document with the orders nested inside it.relational: tables + keysidname7Adaiduser_iditem17book27penuser_id → iddocument: one record, nested{ "name": "Ada","orders": [{ "item": "book" },{ "item": "pen" } ] }documentkey-valuewide-columngraph
Document stores are one kind of NoSQL; key-value, wide-column and graph databases are the others. Which fits depends on how the data is read.

Key takeaways

  • NoSQL means 'not only SQL', not 'no SQL at all'.
  • The main types are document, key-value, wide-column, and graph databases.
  • Many NoSQL databases scale horizontally across many servers.
  • Schemas are usually flexible, so records can have different fields.
  • Choosing SQL or NoSQL depends on your data and how you query it.

Example

Storing and querying documents in MongoDBjavascript
// Using the MongoDB Node.js driver
const users = db.collection("users");

// Documents in the same collection can have different fields
await users.insertOne({ name: "Ada", skills: ["math", "code"] });
await users.insertOne({ name: "Linus", country: "Finland" });

// Find users whose skills array contains "code"
const coders = await users.find({ skills: "code" }).toArray();

Readers ask

What is the difference between SQL and NoSQL?

SQL databases store data in tables with a fixed schema and use SQL for queries, while NoSQL databases use other models such as documents or key-value pairs, usually with a flexible schema. SQL databases are strong at complex queries and consistency; NoSQL databases are often chosen for flexibility and horizontal scale.

Is MongoDB a NoSQL database?

Yes. MongoDB is a document database, one of the most widely used types of NoSQL database, and it stores data as JSON-like documents.

Do NoSQL databases support transactions?

Many modern NoSQL databases, including MongoDB, support multi-document transactions, though the guarantees vary by product. Historically, many NoSQL systems only guaranteed atomic changes to a single record.

Often compared

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings