sql-practice

๐Ÿ—„๏ธ SQL Practice

A structured and practical SQL learning and practice repository designed for beginners, students, self-learners, developers, data analysts, and anyone preparing for SQL interviews.

This repository takes you from SQL fundamentals to advanced concepts, with explanations, examples, practice problems, solutions, challenges, interview questions, and real-world projects.


๐ŸŽฏ Repository Goals

The goal of this repository is to provide a complete, hands-on SQL learning path that helps you:


๐Ÿ› ๏ธ SQL Dialect

This repository primarily uses:

MySQL 8.0+

Examples and exercises are written using MySQL-compatible SQL syntax.

Some SQL features differ between MySQL, PostgreSQL, SQL Server, and other database systems. When relevant, those differences will be mentioned in the notes.


๐Ÿ“š Learning Roadmap

The repository is organized into progressive modules.

๐ŸŸข Beginner SQL

Module Topic
01 SQL Basics
02 Databases & Tables
03 INSERT, UPDATE & DELETE
04 SELECT
05 WHERE
06 ORDER BY
07 DISTINCT & LIMIT
08 Aggregate Functions
09 GROUP BY
10 HAVING

๐ŸŸก Intermediate SQL

Module Topic
11 JOINs
12 Subqueries
13 Set Operations
14 String Functions
15 Date & Time Functions
16 CASE Expressions
17 NULL Handling
18 Constraints
19 Primary & Foreign Keys
20 Views

๐Ÿ”ด Advanced SQL

Module Topic
21 Indexes
22 Common Table Expressions (CTEs)
23 Window Functions
24 Stored Procedures
25 Triggers
26 Transactions
27 Database Normalization

๐Ÿ’ผ Interview Preparation

Module Topic
28 SQL Interview Questions

๐Ÿ“Š Real-World Projects

Module Project
29 SQL Projects

๐Ÿ“ Repository Structure

sql-practice/
โ”‚
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ CODE_OF_CONDUCT.md
โ”œโ”€โ”€ .gitignore
โ”‚
โ”œโ”€โ”€ 01_sql_basics/
โ”œโ”€โ”€ 02_databases_and_tables/
โ”œโ”€โ”€ 03_insert_update_delete/
โ”œโ”€โ”€ 04_select/
โ”œโ”€โ”€ 05_where/
โ”œโ”€โ”€ 06_order_by/
โ”œโ”€โ”€ 07_limit_distinct/
โ”œโ”€โ”€ 08_aggregate_functions/
โ”œโ”€โ”€ 09_group_by/
โ”œโ”€โ”€ 10_having/
โ”‚
โ”œโ”€โ”€ 11_joins/
โ”œโ”€โ”€ 12_subqueries/
โ”œโ”€โ”€ 13_set_operations/
โ”œโ”€โ”€ 14_string_functions/
โ”œโ”€โ”€ 15_date_functions/
โ”œโ”€โ”€ 16_case/
โ”œโ”€โ”€ 17_null_handling/
โ”œโ”€โ”€ 18_constraints/
โ”œโ”€โ”€ 19_keys/
โ”œโ”€โ”€ 20_views/
โ”‚
โ”œโ”€โ”€ 21_indexes/
โ”œโ”€โ”€ 22_ctes/
โ”œโ”€โ”€ 23_window_functions/
โ”œโ”€โ”€ 24_stored_procedures/
โ”œโ”€โ”€ 25_triggers/
โ”œโ”€โ”€ 26_transactions/
โ”œโ”€โ”€ 27_normalization/
โ”‚
โ”œโ”€โ”€ 28_interview_questions/
โ”‚
โ””โ”€โ”€ 29_projects/

๐Ÿ“‚ Module Structure

Most learning modules follow the same structure:

01_sql_basics/
โ”‚
โ”œโ”€โ”€ notes.md
โ”œโ”€โ”€ examples.sql
โ”œโ”€โ”€ practice.sql
โ”œโ”€โ”€ solutions.sql
โ””โ”€โ”€ challenge.sql

๐Ÿ“˜ notes.md

Contains explanations of the topic, syntax, important concepts, and common mistakes.

๐Ÿ’ป examples.sql

Contains commented SQL examples demonstrating the concepts.

๐Ÿ“ practice.sql

Contains exercises for practicing the topic.

โœ… solutions.sql

Contains solutions to the practice exercises.

Try solving the questions yourself before looking at the solutions.

๐Ÿš€ challenge.sql

Contains more challenging problems designed to improve SQL problem-solving skills.


๐Ÿ“Š Practice Difficulty

Exercises are organized by difficulty.

๐ŸŸข Easy

Focuses on understanding basic syntax and individual concepts.

๐ŸŸก Medium

Combines multiple SQL concepts and requires more reasoning.

๐Ÿ”ด Hard

Requires advanced query logic and problem-solving.

๐Ÿ† Challenge

Interview-style or real-world problems designed to test your understanding.


๐Ÿ—ƒ๏ธ Practice Database

The repository will use realistic datasets throughout the learning process.

Example tables may include:

students
courses
employees
departments
customers
orders
products

Using consistent datasets makes it easier to practice increasingly advanced SQL concepts without constantly learning a new database structure.


๐Ÿ“ˆ Learning Progress

Track your progress as you work through the repository.

Beginner

Intermediate

Advanced

Interview Preparation

Projects


๐Ÿง  What You Will Learn

By completing this repository, you will practice:


๐Ÿ’ป Getting Started

1. Clone the Repository

git clone https://github.com/your-username/sql-practice.git

2. Navigate to the Repository

cd sql-practice

3. Install MySQL

Install MySQL 8.0 or later on your computer.

4. Open MySQL

You can use MySQL through:

5. Start Practicing

Navigate to any module:

01_sql_basics/

Read the notes, study the examples, solve the practice problems, and then check your answers against the solutions.


For the best results, follow this cycle:

Learn
  โ†“
Read the Notes
  โ†“
Study the Examples
  โ†“
Write Queries Yourself
  โ†“
Solve Practice Problems
  โ†“
Check Solutions
  โ†“
Attempt the Challenge
  โ†“
Build Projects

Avoid simply copying the solutions.

The goal is to develop the ability to think in SQL and solve problems independently.


๐Ÿ’ผ SQL Interview Preparation

The repository will gradually include SQL interview questions covering:

The interview section will focus on both conceptual questions and practical query-writing problems.


๐Ÿ“Š Projects

The project section will apply the concepts learned throughout the repository to realistic scenarios.

Planned projects include:

๐ŸŽ“ Student Database

Practice:

๐Ÿ“š Library Database

Practice:

๐Ÿ›’ E-commerce Database

Practice:

๐Ÿ‘จโ€๐Ÿ’ผ Employee Database

Practice:

๐Ÿ“ˆ Sales Analysis

Practice:


๐ŸŒŸ Repository Features

This repository aims to provide:


๐Ÿค Contributing

Contributions are welcome!

If you find an error, have a useful SQL exercise, or want to improve the learning material, please read the Contributing Guidelines.


๐Ÿ“œ Code of Conduct

Please read the Code of Conduct before contributing to this repository.


๐Ÿ“„ License

This project is licensed under the MIT License.

See the LICENSE file for more information.


โญ Support the Project

If you find this repository useful for learning SQL or preparing for interviews, consider giving it a โญ on GitHub.

Your support helps the project grow and encourages the creation of more learning resources.


๐Ÿ‘ฉโ€๐Ÿ’ป Author

Shreya Pathak

GitHub: @shreyaapaathakk


Learn SQL. Practice consistently. Solve real problems. Build projects.