Week 8 — DBMS SQL & Schema Design

intermediate dbms dsa

Goal: “In theory, there is no difference between theory and practice. In practice, there is.” — SQL is one of those topics where reading about JOINs means nothing until we write 20 queries. This week we get our hands dirty with real SQL.

Topics

DayTrackFocusTopics
MonA — DSA PracticeGreedy & BacktrackingSolve 2-3 problems. Try activity selection, jump game, or subset generation.
TueB — DBMSSQL QueryingDDL, DML, and DCL · Joins · Subqueries and CTEs · Aggregations, GROUP BY, and HAVING
WedA — DSA PracticeIntervals & Binary SearchSolve 2-3 problems. Merge intervals, insert interval, and binary search on answer variants.
ThuB — DBMSAdvanced SQL & ModelingWindow Functions · Views and Materialized Views · Stored Procedures and Triggers · ER Diagrams
FriB — DBMSSchema DesignNormalization · Denormalization · Relationships and Keys · Schema Design Patterns · Database Migrations

Key Concepts

  • JOINs are the most asked SQL topic in interviews — know INNER, LEFT, RIGHT, FULL, CROSS, and SELF joins cold. Draw Venn diagrams if it helps, but understand that JOINs are really about combining rows based on a condition.
  • Window functions (ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD) are increasingly popular in interviews. They let us compute across rows without collapsing the result set like GROUP BY does.
  • CTEs (Common Table Expressions) make complex queries readable. Recursive CTEs are especially useful for hierarchical data (org charts, category trees).
  • Normalization reduces data redundancy — aim for 3NF in most cases. Denormalization is the intentional reversal for read performance. Neither is “better” — it depends on the use case.
  • ER diagrams are how we communicate schema design visually. Get comfortable drawing entities, relationships, and cardinality (1:1, 1:N, M:N).

Practice

  • DSA: Solve 5-6 problems this week — greedy, backtracking, and interval problems
  • DBMS: Write 5 SQL queries using different types of JOINs (at least one self-join and one with a subquery)
  • DBMS: Write 3 queries using window functions — ranking, running totals, and comparing with previous rows
  • DBMS: Design an ER diagram for a simple e-commerce system (users, products, orders, reviews) and normalize it to 3NF

~13 topics + DSA practice · ~2 hrs/day · Dual-track: DBMS SQL + DSA coding