Repository for learning SQL and databases with exercises, queries, and practice projects.
databases-sql-learning/
│
├── sql_basics/ # SQL fundamentals and basic concepts
├── queries/ # SQL query examples with explanations
└── mysql_projects/ # Complete database projects
Fundamental SQL concepts with simple explanations:
- SELECT - Retrieving data from tables
- WHERE - Filtering data
- JOIN - Combining data from multiple tables
- INSERT, UPDATE, DELETE - Modifying data
- GROUP BY - Grouping and aggregating data
- ORDER BY - Sorting results
- Subqueries - Nested queries
- Functions - Built-in SQL functions
- Indexes - Performance optimization
- Views - Virtual tables
SQL queries organized by difficulty level:
- Simple SELECT statements
- Basic WHERE conditions
- Single table operations
- Basic sorting and filtering
- Multiple JOINs
- Subqueries
- GROUP BY with HAVING
- String and date functions
- Complex multi-table queries
- Window functions
- Query optimization
- Performance tuning
Complete database projects with schemas and queries:
| Project | Description | Status |
|---|---|---|
| Library Management | Books, members, borrowing system | Completed |
| Online Store | Products, orders, customers | Completed |
| Hospital System | Patients, doctors, appointments | In Progress |
| School Database | Students, courses, grades | Planned |
Each project includes:
- Database schema
- Sample data
- Common queries
- Documentation
- MySQL 8.0+ or PostgreSQL
- SQL client (MySQL Workbench, DBeaver, etc.)
- Clone the repository:
git clone https://github.com/ZeyadGabr1/databases-sql-learning.git
cd databases-sql-learning- Set up MySQL:
mysql -u root -p- Run a project:
mysql -u root -p < mysql_projects/project-name/schema.sql
mysql -u root -p < mysql_projects/project-name/data.sql- Open API docs at
http://localhost:8000/docs
Each query includes:
- Description of what it does
- Explanation of concepts used
- Expected output
- Real-world use case
Example:
-- Get all users who registered this month
SELECT name, email, registration_date
FROM users
WHERE registration_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)
ORDER BY registration_date DESC;- MySQL Documentation
- SQLBolt - Interactive tutorial
- LeetCode SQL - Practice problems
Feel free to add queries, projects, or improve documentation.
MIT License - see LICENSE file.
Open an issue or email: [[email protected]]