sql core concepts

πŸ“… 19 Jul 2025

View on Github β†—

date: 2025-07-19 topics: [sql, database, transactions, isolation, backend] day: 4

πŸ“˜ Day 4 – Core SQL Concepts Revised + Hands-On Practice

βœ… What I Worked On

  • Revised foundational SQL topics using hands-on CLI practice
  • Created markdown notes with query examples
  • Simulated transaction isolation anomalies in PostgreSQL
  • Documented all concepts with diagrams + real-world analogies

πŸ“š What I Learned

  • βœ… Transactions: BEGIN, COMMIT, ROLLBACK β€” atomic, consistent operations
  • βœ… ACID Properties:
    • A – Atomicity: All or nothing (e.g., β‚Ή100 isn’t deducted if transfer fails)
    • C – Consistency: Always valid data (e.g., no -β‚Ή50 balances)
    • I – Isolation: No user clashes (e.g., only one person books a seat)
    • D – Durability: Changes survive crashes (e.g., your booking is saved even after a power cut)
  • βœ… Isolation Levels (with hands-on examples):
    • πŸ”Ή READ UNCOMMITTED β†’ dirty reads allowed
    • πŸ”Ή READ COMMITTED β†’ no dirty reads; non-repeatable reads possible
    • πŸ”Ή REPEATABLE READ β†’ consistent row reads; phantom reads may occur
    • πŸ”Ή SERIALIZABLE β†’ strictest; full isolation, full locking
  • βœ… Normalization:
    • 1NF β†’ Atomic columns
    • 2NF β†’ Remove partial dependency
    • 3NF β†’ Remove transitive dependency
  • βœ… Database Design: foreign keys, indexing strategies, table relationships
  • βœ… SQL Axioms & Keys:
    • Primary Key
    • Foreign Key
    • Composite Key
    • Candidate Key

❌ Blockers

  • Took time to simulate and understand isolation-level behaviors (e.g., phantom reads)
  • Differentiating REPEATABLE READ and SERIALIZABLE in practice

🧠 Reflection

Finally got clarity on why ACID matters in real-world apps β€” banking, ticketing, and payments. Simulating SQL anomalies in real-time made it all click. Isolation levels are no longer just theory β€” I can explain and apply them.

πŸ“Έ Isolation Level Visuals

πŸ” Repeatable Read

Repeatable Read

πŸ”’ Serializable

Serializable

πŸ‘€ Read Committed

READ COMMITTED

🚫 Read Uncommitted

READ UNCOMMITTED

πŸ”— References / Code