This roadmap is tailored for backend developers who want to master SQL fundamentals, performance optimization, and real-world database design for production systems. It covers PostgreSQL and MySQL, with light ORM usage (Prisma/TypeORM) near the end.
Understand what SQL is, how databases work, and how to perform essential CRUD operations.
- What is SQL? (vs NoSQL)
- PostgreSQL vs MySQL β key differences
- SQL syntax & structure
- SELECT, INSERT, UPDATE, DELETE
- WHERE, ORDER BY, LIMIT, OFFSET
- DISTINCT, BETWEEN, IN, LIKE
- Basic functions (COUNT, AVG, MAX, MIN, SUM)
- Aliases & comments
SELECT name, email FROM users WHERE active = true ORDER BY created_at DESC;- Simple User Database β CRUD operations on a
userstable. - Library Management DB β manage books, borrowers, and loans.
- Database keys (Primary, Foreign, Composite)
- One-to-One, One-to-Many, Many-to-Many
- INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN
- UNION, INTERSECT, EXCEPT
- Subqueries & Nested SELECT
- Aggregation & GROUP BY + HAVING
SELECT d.name AS department, COUNT(e.id) AS employee_count
FROM departments d
JOIN employees e ON d.id = e.department_id
GROUP BY d.name
HAVING COUNT(e.id) > 5;- Blog DB β users, posts, comments
- E-commerce DB β customers, products, orders, order_items
- Views (materialized & regular)
- Stored Procedures & Functions
- Triggers & Events
- Transactions (COMMIT, ROLLBACK, SAVEPOINT)
- CTEs (Common Table Expressions)
- Window Functions (ROW_NUMBER, RANK, DENSE_RANK)
- Error handling in SQL
CREATE OR REPLACE FUNCTION update_user_activity()
RETURNS TRIGGER AS $$
BEGIN
UPDATE users SET last_active = NOW() WHERE id = NEW.user_id;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;- Banking DB β simulate deposits, transfers, and logs using transactions.
- Analytics Dashboard DB β use window functions to generate leaderboards.
- ER Diagrams (Entity-Relationship models)
- Database normalization (1NF β 3NF, BCNF)
- Referential Integrity
- Cascading deletes & updates
- Data Types & Constraints
- Indexing basics (B-Tree, Hash, GIN, BRIN)
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
customer_id INT REFERENCES customers(id) ON DELETE CASCADE,
total NUMERIC(10,2) NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);- School Management DB β teachers, students, courses, enrollments.
- Inventory System β products, suppliers, stock, transactions.
- Indexing strategies & EXPLAIN ANALYZE
- Query optimization & caching
- Batch inserts & bulk updates
- Partitioning large tables
- Connection pooling (PgBouncer / MySQL Pool)
- VACUUM & ANALYZE (Postgres)
- Handling deadlocks & slow queries
EXPLAIN ANALYZE
SELECT * FROM orders WHERE total > 1000;- Performance Benchmark β compare queries with and without indexes.
- Log Monitor β analyze query logs and detect slow queries.
- What is an ORM and when to use one
- Prisma (Node.js) β schema.prisma basics
- TypeORM / Sequelize quick start
- Migrations, seeding & schema sync
- Raw SQL vs ORM Queries
const users = await prisma.user.findMany({
where: { active: true },
include: { posts: true }
});- Next.js + Prisma + PostgreSQL β basic blog API.
- Express + TypeORM + MySQL β order management API.
- Database migrations & version control
- Backups & restore (pg_dump, mysqldump)
- Replication, Sharding & Failover
- Security (roles, grants, SSL connections)
- Using Docker for local databases
- Cloud services (RDS, Supabase, PlanetScale)
- Production-ready DB Setup β Dockerized PostgreSQL with migrations.
- Monitoring Dashboard β visualize DB metrics (CPU, query time, etc.).
- E-commerce Backend (products, users, orders, payments)
- Learning Management System (LMS) β courses, quizzes, progress tracking
- Banking API β account balances, transfers, and transactions
- Analytics API β leaderboards, KPIs, and dashboards
- Social Network Backend β users, follows, posts, likes
sql-backend-roadmap/
βββ 01-fundamentals/
β βββ users.sql
β βββ library.sql
βββ 02-joins-and-relationships/
β βββ blog.sql
β βββ ecommerce.sql
βββ 03-advanced-sql/
β βββ banking.sql
β βββ analytics.sql
βββ 04-design-and-normalization/
β βββ school_management.sql
β βββ inventory.sql
βββ 05-optimization/
β βββ benchmarks.sql
β βββ query_analysis.sql
βββ 06-orms/
β βββ prisma-example/
β βββ typeorm-example/
βββ 07-production/
β βββ docker-compose.yml
β βββ migrations/
β βββ monitoring/
βββ README.md
- Master SQL fundamentals in both PostgreSQL & MySQL.
- Build real schemas and test queries daily.
- Integrate SQL into your backend projects.
- Optimize, index, and scale like a pro.
π― Goal: Become a backend engineer who writes efficient, scalable, and production-ready SQL.