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

# Database and file system

## Database types

![](https://3398971849-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M9HSM8Jn9nrPTh34ajG%2Fuploads%2Fgit-blob-3430b0d41dc9675abba30d02c834fddb4df5f23d%2Fimage.png?alt=media)

## SQL v.s. NoSQL

* SQL
  * Pros
    * support transaction, which is good for financial application.
    * structure data: use structured query language and have a predefined schema
      * analytic scenario?
  * Cons
    * hard to scale out
    * low availability
      * low throughput, qps is generally lower than NoSQL DB
* NoSQL
  * Pros
    * dynamic schema
    * highly available: eventual consistent, replication
    * highly and easily scalable
    *

![](https://3398971849-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M9HSM8Jn9nrPTh34ajG%2Fuploads%2Fgit-blob-566eabe69b286efe603adc818bb40ebadfa6c41e%2Fimage.png?alt=media)

## Distributed database

![](https://3398971849-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M9HSM8Jn9nrPTh34ajG%2Fuploads%2Fgit-blob-0b00bc3ff4e4fa724a3f9a2a9d81375da73038c6%2Fimage.png?alt=media)

![](https://3398971849-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M9HSM8Jn9nrPTh34ajG%2Fuploads%2Fgit-blob-13707f48e75a922025d174f49004c572b5e0dd02%2Fimage.png?alt=media)

![](https://3398971849-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M9HSM8Jn9nrPTh34ajG%2Fuploads%2Fgit-blob-59934fab28f6ffd4c3dc6bf2a98aa452ca188c5d%2Fimage.png?alt=media)
