> For the complete documentation index, see [llms.txt](https://liuzhenglaichn.gitbook.io/system-design/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://liuzhenglaichn.gitbook.io/system-design/basics/sql-vs-nosql.md).

# SQL vs NoSQL

SQL: relational database store data in tables which are formed in rows and columns.&#x20;

NoSQL:&#x20;

* key-value
* document
* graph

## High level differences

### Storage

SQL: table

NoSQL: key-value, document, graph.

### Schema

SQL: fixed

NoSQL: dynamic

### Querying

SQL: uses SQL (structured query language)

NoSQL: UnQL (unstructured query language).

### Scalability

SQL: vertically scalable. Hard to horizontally scale

NoSQL: horizontally scalable.

### Reliability or ACID Compliancy (Atomicity, Consistency, Isolation, Durability)

SQL: ACID compliant

NoSQL: sacrifice ACID compliance for performance and scalability.

## Ideal Applications

<https://www.sitepoint.com/sql-vs-nosql-differences/>

### Projects where SQL is ideal

* logical related discrete data requirements which can be identified up-front
* data integrity is essential
* standards-based proven technology with good developer experience and support.

### **Projects where NoSQL is ideal**

* unrelated, indeterminate or evolving data requirements
* simpler or looser project objectives, able to start coding immediately
* speed and scalability is imperative.

<https://github.com/donnemartin/system-design-primer#sql-or-nosql>

* Rapid ingest of clickstream and log data
* Leaderboard or scoring data
* Temporary data, such as a shopping cart
* Frequently accessed ('hot') tables
* Metadata/lookup tables


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://liuzhenglaichn.gitbook.io/system-design/basics/sql-vs-nosql.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
