Tags

  • AWS (7)
  • Apigee (3)
  • ArchLinux (5)
  • Array (6)
  • Backtracking (6)
  • BinarySearch (6)
  • C++ (19)
  • CI&CD (3)
  • Calculus (2)
  • DesignPattern (43)
  • DisasterRecovery (1)
  • Docker (8)
  • DynamicProgramming (20)
  • FileSystem (11)
  • Frontend (2)
  • FunctionalProgramming (1)
  • GCP (1)
  • Gentoo (6)
  • Git (15)
  • Golang (1)
  • Graph (10)
  • GraphQL (1)
  • Hardware (1)
  • Hash (1)
  • Kafka (1)
  • LinkedList (13)
  • Linux (27)
  • Lodash (2)
  • MacOS (3)
  • Makefile (1)
  • Map (5)
  • MathHistory (1)
  • MySQL (21)
  • Neovim (10)
  • Network (66)
  • Nginx (6)
  • Node.js (33)
  • OpenGL (6)
  • PriorityQueue (1)
  • ProgrammingLanguage (9)
  • Python (10)
  • RealAnalysis (20)
  • Recursion (3)
  • Redis (1)
  • RegularExpression (1)
  • Ruby (19)
  • SQLite (1)
  • Sentry (3)
  • Set (4)
  • Shell (3)
  • SoftwareEngineering (12)
  • Sorting (2)
  • Stack (4)
  • String (2)
  • SystemDesign (13)
  • Terraform (2)
  • Tree (24)
  • Trie (2)
  • TwoPointers (16)
  • TypeScript (3)
  • Ubuntu (4)
  • Home

    SQL vs. NoSQL

    Published Jul 16, 2022 [  SystemDesign  ]

    Relational databases are structured and have a predefined schemas like phone books that store phone numbers and addresses. Non-relational databases are unstructured, distributed, and have a dynamic schema like file folders that hold everything from a person’s address and phone number to their Facebook ‘likes’ and online shopping preferences.

    SQL

    Relational databases store data in rows and columns. Each row contains all the information about one entity and each column contains all the separate data points.

    NoSQL

    • Key-Value Stores:
      • Data is stored in an array of key-value paris. The ‘key’ ia an attribute name which is linked to a ‘value’. Well-known key-value stores include Redis, Dynamo.
    • Document Databases:
      • Data is stored in documents and these documents are grouped together in collections. Each document can have an entirely different structure. MongoDB.
    • Wide-Column Databases:
      • Instead of ‘tables’, in columnar databases we have column families, which are containers for rows. Unlike relational databases, we don’t need to know all the columns upfront and each row doesn’t have to have the same number of columns. Columnar databases are best suited for analyzing large datasets - Cassandra and HBase
    • Graph Database
      • These databases are used to store data whose relations are best represented in a graph. Data is saved in graph structures with nodes (entities) , properties (information about the entities), and lines (connections between the entities). Neo4j and InfiniteGraph.

    High Level Differences between SQL and NoSQL

    • Storage
      • SQL stores data in tables where each row represents an entity and each column represents a data point about that entity
      • NoSQL database have different data storage models. The main ones are key-value, document, graph, and columnar.
    • Schema
      • In SQL, each record conforms to a fixed schema, meaning the columns must be decided and chose before data entry and each row must have data for each column.
      • In NoSQL, schemas are dynamic. Columns can be added on the fly and each ‘row’ (or equivalent) doesn’t have to contain for each ‘column’
    • Querying
      • SQL data bases use SQL. In a NoSQL database, queries are focused on a collection of documents. Sometimes it is also called UnQL (Unstructured Query Language)
    • Scalability
      • SQL databases are vertically scalable.
      • NoSQL databases are horizontally scalable
    • Reliability or ACID Compliancy (Atomicity, Consistency, Isolation, Durability)
      • The vast majority of relational databases are ACID compliant.
      • Most of the NoSQL solutions sacrifice ACID compliance for performance and scalability.

    SQL vs. NoSQL - Which one to use?

    Reasons to use SQL database

    1. We need to enure ACID compliance.
    2. Your data is structured and unchanging.

    Reasons to use NoSQL database

    1. Storing large volumes of data that often have little to no structure.
    2. Making the most of cloud computing and storage.
    3. Rapid development.