Week 11 — HLD Databases & More Graphs

intermediate hld python dsa

Goal: Go deep on how databases scale in distributed systems — replication, sharding, and consistent hashing are interview favorites. Keep Python and graph algorithms moving forward.

Topics

DayFocusTopics
MonHLD Database BasicsSQL vs NoSQL · Database Indexing · Database Replication
TueHLD Database ScalingDatabase Sharding · Consistent Hashing · ACID and Transactions
WedPython InternalsLEGB Scope Rule · Shallow vs Deep Copy · Exception Handling
ThuDSA Graph AlgorithmsTopological Sort · Shortest Path Algorithms
FriDSA Advanced GraphsUnion-Find

Key Concepts

  • Master-slave vs multi-master replication — consistency vs availability tradeoffs
  • Horizontal vs vertical sharding strategies — range-based, hash-based, and directory-based
  • Consistent hashing ring — why it minimizes data movement when nodes join or leave
  • Python’s LEGB scope resolution — Local, Enclosing, Global, Built-in
  • Shallow vs deep copy pitfalls — nested mutable objects are where bugs hide
  • Dijkstra’s vs Bellman-Ford — greedy vs relaxation, and when negative edges matter
  • Union-Find with path compression and union by rank — near O(1) amortized operations

Practice

  • Design a sharding strategy for a user table with 100M rows — justify your shard key choice
  • Implement Dijkstra’s algorithm from scratch — test it on a weighted graph
  • Implement Union-Find with both path compression and union by rank
  • Write code that demonstrates the difference between shallow and deep copy with nested lists

~12 topics · ~1.5-2 hrs/day · Focus: read the linked notes, then code each concept