Skip to content

Instantly share code, notes, and snippets.

@SamirPaulb
Created March 25, 2023 18:49
Show Gist options
  • Save SamirPaulb/075ebc90d262dbdf4c9538c3d47669db to your computer and use it in GitHub Desktop.
Save SamirPaulb/075ebc90d262dbdf4c9538c3d47669db to your computer and use it in GitHub Desktop.
SQL vs. NoSQL ~ Scalability, Querying, Schema

Common types of NoSQL

Key-value stores

  • Array of key-value pairs. The "key" is an attribute name.
  • Redis, Vodemort, Dynamo.

Document databases

  • Data is stored in documents.
  • Documents are grouped in collections.
  • Each document can have an entirely different structure.
  • CouchDB, MongoDB.

Wide-column / columnar databases

  • Column families - containers for rows.
  • No need to know all the columns up front.
  • Each row can have different number of columns.
  • Cassandra, HBase.

Graph database

  • Data is stored in graph structures
    • Nodes: entities
    • Properties: information about the entities
    • Lines: connections between the entities
  • Neo4J, InfiniteGraph

Differences between SQL and NoSQL

Storage

  • SQL: store data in tables.
  • NoSQL: have different data storage models.

Schema

  • SQL
    • Each record conforms to a fixed schema.
    • Schema can be altered, but it requires modifying the whole database.
  • NoSQL:
    • Schemas are dynamic.

Querying

  • SQL
    • Use SQL (structured query language) for defining and manipulating the data.
  • NoSQL
    • Queries are focused on a collection of documents.
    • UnQL (unstructured query language).
    • Different databases have different syntax.

Scalability

  • SQL
    • Vertically scalable (by increasing the horsepower: memory, CPU, etc) and expensive.
    • Horizontally scalable (across multiple servers); but it can be challenging and time-consuming.
  • NoSQL
    • Horizontablly scalable (by adding more servers) and cheap.

ACID

  • Atomicity, consistency, isolation, durability
  • SQL
    • ACID compliant
    • Data reliability
    • Gurantee of transactions
  • NoSQL
    • Most sacrifice ACID compliance for performance and scalability.

Which one to use?

SQL

  • Ensure ACID compliance.
    • Reduce anomalies.
    • Protect database integrity.
  • Data is structured and unchanging.

NoSQL

  • Data has little or no structure.
  • Make the most of cloud computing and storage.
    • Cloud-based storage requires data to be easily spread across multiple servers to scale up.
  • Rapid development.
    • Frequent updates to the data structure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment