📋
space
  • SDE Interview
  • Multi-threading
    • Mutex vs Semorphore
    • Thread vs process
  • Design Pattern
  • Java
    • Polymorphism
    • Encapsulation
    • Inheritance
    • Override vs overload
  • MySQL
    • DB transaction
  • Data Structure
    • Design hashset
    • AVL / red black tree
    • LinkedList vs arrayList
    • HashMap vs HashTable
    • Binary Tree
    • Heap
  • System Design
    • Session Cookie
    • GFS / BigTable / MapReduce
    • Zookeeper
    • gRPC vs thrift
    • Amazon RDS vs Oracle
    • Microservices
    • REST vs RPC
    • Database design
    • idempotent in HTTP
    • Optimistic locking / Pessimistic locking
    • Partitioning / Sharding data
    • Consistent Hashing
    • Case Study
      • Design Delay Task scheduler
      • Design View Count
      • Design Twitter
      • Design Web Crawler
      • Design Uber
      • Design Netflix
      • Design Google Doc
      • Design Monitoring System
      • Design Dropbox
      • Distributed Lock
      • Design Instagram
      • Design Yelp
      • Design Amazon
      • Design Google Search
      • Distributed Database System Key Value Store
      • Design Facebook message / Whatsapp
      • Design Logging Systems
      • Design Movie booking system
      • Design Google Autocomplete Feature
      • Design Twitter Search
    • Message Broker
      • Kafka
    • Design Data Intensive Application
      • Chapter 8
    • SQL vs NoSQL
      • Cassandra
      • MongoDB vs Cassandra vs MySQL vs HBase
    • TCP vs UDP
    • Load Balancer
    • Cache
      • Memcached
      • Redis
    • DNS
    • CDN
    • Strong consistency vs eventual consistency
    • Scalability
Powered by GitBook
On this page
  • SQL
  • When to use:
  • Reasons for SQL:
  • Reasons for NoSQL:
  • Sample data well-suited for NoSQL:
  • NoSQL
  • When to choose NoSQL database

Was this helpful?

  1. System Design

SQL vs NoSQL

ACID vs BASE, relational prefer consistency and NoSQL DB prefer availability

SQL

It stores data in row & columns

  • MySQL, Oracle, SQLite

  • Each record has fixed schema, columns must be decides before data entry, can be altered but involves modifying whole database & going offline

  • It uses SQL Query

  • SQL are vertically scalable i.e. by increasing the higher memory, CPU of hardware, which can be very expensive

  • Most of SQLs are ACID compliant (Atomic, Consistency, Isolation, Durability)

  • When you want to ensure ACID compliance & your data is structured & unchanging.

When to use:

  • when schema not likely to change much

  • when you want to ensure ACID compliance & your data is structured & unchanging

Reasons for SQL:

  • Structured data

  • Strict schema

  • Relational data

  • Need for complex joins

  • Transactions

  • Clear patterns for scaling

  • More established: developers, community, code, tools, etc

  • Lookups by index are very fast

Reasons for NoSQL:

  • Semi-structured data

  • Dynamic or flexible schema

  • Non-relational data

  • No need for complex joins

  • Store many TB (or PB) of data

  • Very data intensive workload

  • Very high throughput for IOPS

Sample data well-suited for 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

NoSQL

  • Here schemas are dynamic, columns can be added on the fly & each row doesn't have to be contain each columns

  • Here queries are focused on a collection of documents. It's also known as UNQL (Unstructured Query language)

  • These are horizontally scalable meaning we can add more servers easily. Lot of servers are distributed data servers also.

  • Most of NoSQL sacrifice ACID compliance for performance & scalability.

  • When storing large volume of data with rapid development with no structure fixed.

  • Cloud based computing & storage. They are designed to be scaled across multiple data servers

NoSQL: Common types

  • Key-Value stores: Redis, Voldemart, DynamoDB

  • Document databases(JSON, XML): MongoDB, CouchDB

  • Wide-Column database:

    • Column families

    • Best suited for analyzing large dataset

    • Cassendra, HBase

  • Graph Database:

    • Data is saved in graph structure with nodes(entities), properties & lines(Connection)

    • Neo4J, InfiniteGraph

When to choose NoSQL database

  • when schemas are dynamic

  • when storing large volume of data with rapid development with no structure fixed

  • when data needs to be stored across servers in different regions

PreviousChapter 8NextCassandra

Last updated 4 years ago

Was this helpful?