DEV Community

Sreekar Reddy
Sreekar Reddy

Posted on • Originally published at sreekarreddy.com

πŸ’Ύ SQL vs NoSQL Explained Like You're 5

Filing cabinet vs storage bins

Day 14 of 149

πŸ‘‰ Full deep-dive with code examples


Two Ways to Store Things

Filing Cabinet (SQL):

  • Organized folders
  • Each drawer has same structure
  • Everything has a place
  • Finding things: easy!

Storage Bins (NoSQL):

  • Flexible containers
  • Throw anything in
  • Different boxes, different stuff
  • Finding things: depends!

SQL Databases

Structured Query Language

Think spreadsheets with strict rules:

id name email age
1 Sreekar sreekar@email.com 25
2 Alex alex@email.com 30

Rules:

  • Every row has same columns
  • Can't add random new columns
  • Data types are usually enforced (age is typically a number)

Good for: Banking, orders, anything needing consistency


NoSQL Databases

NoSQL databases often have more flexible structure

{
  "name": "Sreekar",
  "email": "sreekar@email.com",
  "hobbies": ["coding", "reading"],
  "address": {
    "city": "Sydney"
  }
}
Enter fullscreen mode Exit fullscreen mode

Can store:

  • Different fields per record
  • Nested data
  • Lists and objects

Good for: Social media, real-time apps, changing requirements


Quick Comparison

SQL NoSQL
Tables with rows Documents or key-value
Fixed structure Flexible structure
Joins are easy Joins are hard
Scale vertically Scale horizontally
MySQL, PostgreSQL MongoDB, Redis

In One Sentence

SQL uses rigid tables for structured data; NoSQL uses flexible formats for varied, evolving data.


πŸ”— Enjoying these? Follow for daily ELI5 explanations!

Making complex tech concepts simple, one day at a time.

Top comments (0)