Labs ICT
โญ Pro Login

NoSQL Databases

When relational isn't enough โ€” document, key-value, graph, and column stores.

Beyond Tables

NoSQL (Not Only SQL) databases are designed for specific use cases where relational databases aren't ideal โ€” massive scale, flexible schemas, or specialized data structures. They don't use SQL as their primary query language.

NoSQL Database Types


  Document Store              Key-Value Store
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚ {                  โ”‚      โ”‚ "user:1"โ”‚{name:Alice}โ”‚
  โ”‚   "_id": "123",    โ”‚      โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
  โ”‚   "name": "Alice", โ”‚      โ”‚ "user:2"โ”‚{name:Bob}  โ”‚
  โ”‚   "age": 25,       โ”‚      โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
  โ”‚   "courses":       โ”‚      โ”‚ "sess:5"โ”‚"abc123"    โ”‚
  โ”‚     ["DB", "Net"]  โ”‚      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  โ”‚ }                  โ”‚      Redis, DynamoDB
  MongoDB, CouchDB

  Column-Family              Graph Database
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”    (Alice)โ”€โ”€knowsโ”€โ”€โ†’(Bob)
  โ”‚ Row โ”‚ Col1  โ”‚ Col2 โ”‚     โ”‚                  โ”‚
  โ”œโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ค     โ”‚                  โ”‚
  โ”‚  1  โ”‚ Alice โ”‚ 25   โ”‚   knows              knows
  โ”‚  2  โ”‚ Bob   โ”‚ 30   โ”‚     โ”‚                  โ”‚
  โ”‚  3  โ”‚ Carol โ”‚ 28   โ”‚   (Carol)โ†knowsโ”€โ”€(Dave)
  โ””โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  Cassandra, HBase        Neo4j, ArangoDB

When to Use NoSQL


  Use NoSQL when:                Use SQL when:
  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  โœ“ Schema is evolving rapidly   โœ“ Data is highly structured
  โœ“ Massive horizontal scale     โœ“ Complex queries & JOINs
  โœ“ Real-time analytics          โœ“ ACID transactions needed
  โœ“ Simple key-value lookups     โœ“ Data consistency critical
  โœ“ Unstructured data            โœ“ Reporting & analytics

CAP Theorem


  You can only guarantee TWO of three:

        Consistency
           /\
          /  \
         /    \
        /  CA  \
       /________\
      CP        AP

  CA: Consistency + Availability (traditional RDBMS)
  CP: Consistency + Partition tolerance (MongoDB, HBase)
  AP: Availability + Partition tolerance (Cassandra, DynamoDB)

  In distributed systems, partition tolerance is required,
  so you choose between consistency and availability.

๐Ÿงช Quick Quiz

Which NoSQL database type is best for relationships between data?