Course Overview & Sample Database
What this SQL course covers, how to use it, prerequisites, and the sample database used throughout.
Track: Computer Science → Database / SQL Level: Beginner → Intermediate → Advanced → Expert / Practical
Audience: Students, beginners, developers, software engineers, data engineers, testers, and interview candidates
Course Overview
SQL (Structured Query Language) is the standard language for defining, querying, and managing data in relational databases. Almost every software system eventually stores data in a relational database: banking systems, e-commerce platforms, hospital records, automotive diagnostic tools, test-management systems, analytics warehouses, and mobile apps (through SQLite).
This course takes you from zero knowledge to advanced, production-grade SQL. It is organized as a curriculum of 50 modules grouped into four stages:
Databases, tables, data types, constraints, inserting data, SELECT, filtering, sorting, functions, aggregation, grouping
Joins, subqueries, set operations, CTEs, window functions, views, indexes, performance, transactions, isolation, normalization, relationships
Stored procedures, functions, triggers, temporary tables, sequences, security, SQL injection, backup and recovery, database design, ER modeling Expert / Practical
Real-world databases, automotive SQL, data analysis, date/time analysis, duplicates, NULL handling, advanced patterns, interview preparation, practice problems, projects, debugging, best practices, dialect comparison, roadmap, cheat sheet, quizzes How to Use This Course
Read each module in order. Later modules assume earlier ones.
Type every example yourself. Do not copy-paste; typing builds muscle memory.
Run the examples on a real database. PostgreSQL and SQLite are free and easy to install; MySQL and SQL Server Express are also free.
Complete the practice questions and quizzes before moving on.
Build at least two of the projects in Module 44.
A Note on SQL Dialects SQL is an ISO/ANSI standard, but every database system implements its own dialect. The core (SELECT, INSERT, UPDATE, DELETE, JOIN, GROUP BY) is almost identical everywhere, but details such as auto-generated IDs, pagination, string concatenation, and date functions differ.
In this course:
Examples written in standard SQL work on most modern systems unless noted.
Dialect-specific syntax is clearly labeled, for example:
When no dialect label is shown, the example uses standard SQL that runs on PostgreSQL and, in most cases, on MySQL 8+, SQL Server, Oracle, and SQLite as well.
-- PostgreSQL
SELECT * FROM orders LIMIT 10;
-- SQL Server
SELECT TOP 10 * FROM orders;
-- Standard SQL (PostgreSQL, Oracle 12c+, SQL Server 2012+ with ORDER BY)
SELECT * FROM orders ORDER BY order_id FETCH FIRST 10 ROWS ONLY;Learning Objectives
By the end of this course you will be able to:
Explain what databases, DBMSs, and RDBMSs are and how relational data is organized.
Create databases, tables, and constraints that protect data integrity.
Choose appropriate data types for any column.
Insert, update, delete, and merge data safely.
Write SELECT queries with filtering, sorting, pagination, functions, and conditional logic.
Summarize data with aggregate functions, GROUP BY, and HAVING.
Combine tables with every type of JOIN and predict the result set.
Use subqueries, set operations, CTEs, and recursive CTEs.
Solve analytical problems with window functions (ranking, running totals, moving averages, LAG/LEAD).
Create views, materialized views, and indexes, and understand how indexes work internally.
Read execution plans and troubleshoot slow queries.
Use transactions correctly and understand ACID, isolation levels, locking, and concurrency anomalies.
Design normalized schemas (1NF through 5NF) and know when to denormalize.
Write stored procedures, user-defined functions, and triggers.
Secure a database with users, roles, and privileges, and prevent SQL injection.
Plan backup and recovery using RPO and RTO.
Model real-world systems (e-commerce, banking, hospital, automotive diagnostics) with ER diagrams.
Answer SQL interview questions and solve SQL coding problems confidently.
Prerequisites
Basic computer literacy (installing software, using a terminal or GUI tool).
No prior programming experience is required, although familiarity with any programming language helps in Modules 25 – 27 and 31.
Recommended tools (choose at least one):
psql / pgAdmin / DBeaver Recommended primary database for this course (strong standard compliance) MySQL Workbench / mysql CLI Very common in web development
SQL Server Management Studio / Azure Data Studio Common in enterprise and Windows environments SQL Developer / SQL*Plus Common in large enterprises and banking sqlite3 CLI / DB Browser for SQLite Zero setup, single-file database db-fiddle, sqlfiddle-style sites, useful for quick tests
The Course Sample Database
Most examples in Modules 6 – 22 use the same small company database, so you can predict every result by hand. Create it once and reuse it.
Schema (standard SQL; runs on PostgreSQL, MySQL 8+, SQL Server, SQLite)
Notes: Oracle does not support multi-row VALUES lists in INSERT before version 23ai; use one INSERT per row or INSERT ALL. In Oracle, write date literals as DATE '2026-01-05'. The standard DATE '2026-01-05' literal also works in PostgreSQL and MySQL.
Facts to Remember About the Sample Data Why it matters in examples
Kiran Joshi (emp 7) has dept_id = NULL Demonstrates NULL in joins and GROUP BY Finance (dept 4) has no employees Demonstrates LEFT/RIGHT/FULL joins
Asha Rao (emp 1) has manager_id = NULL Root of the management hierarchy
Diya Patel (customer 4) has email = NULL Demonstrates IS NULL and COALESCE Elena Rossi (customer 5) has no orders Demonstrates anti-joins and NOT EXISTS
Standing Desk (product 106) was never ordered Demonstrates unmatched rows Neha and Meera both earn 95000 Demonstrates RANK vs DENSE_RANK ties
departments 1 ──── N employees (dept_id)
employees 1 ──── N employees (manager_id, self-reference)
customers 1 ──── N orders (customer_id)
orders 1 ──── N order_items (order_id)
products 1 ──── N order_items (product_id)CREATE TABLE departments (
dept_id INT PRIMARY KEY,
dept_name VARCHAR(50) NOT NULL UNIQUE,
location VARCHAR(50) NOT NULL
);
CREATE TABLE employees (
emp_id INT PRIMARY KEY,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
email VARCHAR(100) NOT NULL UNIQUE,
dept_id INT NULL REFERENCES departments(dept_id),
manager_id INT NULL REFERENCES employees(emp_id),
job_title VARCHAR(50) NOT NULL,
salary DECIMAL(10,2) NOT NULL CHECK (salary > 0),
hire_date DATE NOT NULL
);
CREATE TABLE customers (
customer_id INT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) NULL,
city VARCHAR(50) NOT NULL,
country VARCHAR(50) NOT NULL
);
CREATE TABLE products (
product_id INT PRIMARY KEY,
product_name VARCHAR(100) NOT NULL,
category VARCHAR(50) NOT NULL,
price DECIMAL(10,2) NOT NULL CHECK (price >= 0),
stock INT NOT NULL DEFAULT 0
);
CREATE TABLE orders (
order_id INT PRIMARY KEY,
cust
…INSERT INTO departments (dept_id, dept_name, location) VALUES
(1, 'Engineering', 'Bangalore'),
(2, 'Sales', 'Mumbai'),
(3, 'HR', 'Pune'),
(4, 'Finance', 'Delhi');
INSERT INTO employees
(emp_id, first_name, last_name, email, dept_id, manager_id, job_title, salary, hire_date) VALUES
(1, 'Asha', 'Rao', '[email protected]', 1, NULL, 'CTO', 250000, '2015-03-01'),
(2, 'Vikram', 'Shah', '[email protected]', 1, 1, 'Senior Engineer', 150000, '2018-06-15'),
(3, 'Neha', 'Iyer', '[email protected]', 1, 2, 'Engineer', 95000, '2021-01-10'),
(4, 'Rahul', 'Mehta', '[email protected]', 2, 1, 'Sales Manager', 120000, '2017-09-01'),
(5, 'Priya', 'Nair', '[email protected]', 2, 4, 'Sales Executive', 60000, '2022-04-20'),
(6, 'Arjun', 'Das', '[email protected]', 3, 1, 'HR Manager', 90000, '2019-11-05'),
(7, 'Kiran', 'Joshi', '[email protected]', NULL, 1, 'Consultant', 80000, '2023-02-01'),
(8, 'Meera', 'Pillai', '[email protected]', 1, 2, 'Engineer', 95000, '2022-07-18');
INSERT INTO customers (customer_id, name, email, city, country) VALUES
(1
…