Skip to content

AbdullahNamespace/learn-database-by-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ—„๏ธ Learn Database by Practice

๐Ÿ“– About | ุญูˆู„ ุงู„ู…ุดุฑูˆุน

A collection of database exercises for learning through practice โ€” covering both database design (ER modeling, normalization, relationships) and SQL (DDL, DML, DQL, joins, aggregation, subqueries, window functions, and more). Each exercise is documented with clear descriptions in both English and Arabic.

ู…ุฌู…ูˆุนุฉ ู…ู† ุชู…ุงุฑูŠู† ู‚ูˆุงุนุฏ ุงู„ุจูŠุงู†ุงุช ู„ู„ุชุนู„ู… ู…ู† ุฎู„ุงู„ ุงู„ู…ู…ุงุฑุณุฉ โ€” ุชุบุทูŠ ุชุตู…ูŠู… ู‚ูˆุงุนุฏ ุงู„ุจูŠุงู†ุงุช (ู†ู…ุฐุฌุฉ ERุŒ ุงู„ุชุทุจูŠุนุŒ ุงู„ุนู„ุงู‚ุงุช) ูˆ SQL (DDL, DML, DQLุŒ ุงู„ุฌูˆูŠู†ุฒุŒ ุงู„ุชุฌู…ูŠุนุŒ ุงู„ุงุณุชุนู„ุงู…ุงุช ุงู„ูุฑุนูŠุฉุŒ ุฏูˆุงู„ ุงู„ู†ุงูุฐุฉุŒ ูˆุบูŠุฑู‡ุง). ูƒู„ ุชู…ุฑูŠู† ู…ูˆุซู‘ู‚ ุจุฃูˆุตุงู ูˆุงุถุญุฉ ุจุงู„ุฅู†ุฌู„ูŠุฒูŠุฉ ูˆุงู„ุนุฑุจูŠุฉ.

โš ๏ธ Important Note | ู…ู„ุงุญุธุฉ ู…ู‡ู…ุฉ

This repository is different from programming-language repos (like Python/Go/Rust) where every exercise is a standalone, runnable file. Here, exercises are split into two distinct types:

Type ุงู„ู†ูˆุน Executable? ู‚ุงุจู„ ู„ู„ุชู†ููŠุฐุŸ
Design Exercises ุชู…ุงุฑูŠู† ุงู„ุชุตู…ูŠู… โŒ No โŒ ู„ุง
SQL Exercises ุชู…ุงุฑูŠู† SQL โœ… Yes โœ… ู†ุนู…

Each type has its own template. See the Templates section below.

ู‡ุฐุง ุงู„ู…ุณุชูˆุฏุน ู…ุฎุชู„ู ุนู† ู…ุณุชูˆุฏุนุงุช ู„ุบุงุช ุงู„ุจุฑู…ุฌุฉ ุญูŠุซ ูƒู„ ุชู…ุฑูŠู† ู„ูŠุณ ุจุงู„ุถุฑูˆุฑุฉ ูƒูˆุฏุงู‹ ู‚ุงุจู„ุงู‹ ู„ู„ุชุดุบูŠู„. ุชู…ุงุฑูŠู† ุงู„ุชุตู…ูŠู… ู…ุฎุฑุฌุงุชู‡ุง ุชุญู„ูŠู„ ูˆู…ุฎุทุทุงุชุŒ ุจูŠู†ู…ุง ุชู…ุงุฑูŠู† SQL ู‡ูŠ ุงุณุชุนู„ุงู…ุงุช ุชูู†ูุฐ ู…ุจุงุดุฑุฉ. ู„ูƒู„ ู†ูˆุน ู‚ุงู„ุจ ุฎุงุต ุจู‡ โ€” ุงู†ุธุฑ ู‚ุณู… ุงู„ู‚ูˆุงู„ุจ ุฃุฏู†ุงู‡.


๐Ÿ“‚ Repository Structure | ู‡ูŠูƒู„ ุงู„ู…ุณุชูˆุฏุน

learn-database-by-practice/
โ”œโ”€โ”€ .gitignore                      # Git ignore file | ู…ู„ู ุชุฌุงู‡ู„ ุงู„ุฌูŠุช
โ”œโ”€โ”€ README.md                       # Project overview | ู†ุธุฑุฉ ุนุงู…ุฉ ุนู„ู‰ ุงู„ู…ุดุฑูˆุน
โ”œโ”€โ”€ template-design.md              # Design problem template | ู‚ุงู„ุจ ุชู…ุงุฑูŠู† ุงู„ุชุตู…ูŠู…
โ”œโ”€โ”€ template-sql.sql                # SQL problem template | ู‚ุงู„ุจ ุชู…ุงุฑูŠู† SQL
โ”‚
โ”œโ”€โ”€ theory/                         # Short concept references | ู…ุฑุฌุน ู…ุฎุชุตุฑ ู„ู„ู…ูุงู‡ูŠู…
โ”‚   โ”œโ”€โ”€ 01_fundamentals.md
โ”‚   โ”œโ”€โ”€ 02_design.md
โ”‚   โ”œโ”€โ”€ 03_ddl.md
โ”‚   โ”œโ”€โ”€ 04_dml.md
โ”‚   โ”œโ”€โ”€ 05_dql_joins.md
โ”‚   โ”œโ”€โ”€ 06_aggregation.md
โ”‚   โ”œโ”€โ”€ 07_subqueries.md
โ”‚   โ”œโ”€โ”€ 08_window_functions.md
โ”‚   โ”œโ”€โ”€ 09_dcl_tcl.md
โ”‚   โ”œโ”€โ”€ 10_indexing.md
โ”‚   โ””โ”€โ”€ 11_advanced.md
โ”‚
โ””โ”€โ”€ problems/                       # All exercises | ุฌู…ูŠุน ุงู„ุชู…ุงุฑูŠู†
    โ”œโ”€โ”€ design/                     # Design exercises | ุชู…ุงุฑูŠู† ุงู„ุชุตู…ูŠู…
    โ”‚   โ”œโ”€โ”€ 0001_normalize_table/
    โ”‚   โ”‚   โ””โ”€โ”€ main.md
    โ”‚   โ”œโ”€โ”€ 0002_er_diagram_from_requirements/
    โ”‚   โ”‚   โ””โ”€โ”€ main.md
    โ”‚   โ””โ”€โ”€ ...
    โ”‚
    โ””โ”€โ”€ sql/                        # SQL exercises | ุชู…ุงุฑูŠู† SQL
        โ”œโ”€โ”€ 0001_create_simple_table/
        โ”‚   โ””โ”€โ”€ main.sql
        โ”œโ”€โ”€ 0002_inner_join_basics/
        โ”‚   โ””โ”€โ”€ main.sql
        โ””โ”€โ”€ ...

Why two problem folders? | ู„ู…ุงุฐุง ูŠูˆุฌุฏ ู…ุฌู„ุฏูŠู† ู„ู„ุชู…ุงุฑูŠู†ุŸ Design exercises produce an analysis or diagram, not runnable code โ€” while SQL exercises (DDL, DML, DQL, joins, aggregation, subqueries, window functions, DCL/TCL, indexing, advanced objects) are all executed the same way, and often mix several topics in a single query. So design/ is kept separate, while all SQL topics stay flat under sql/ instead of being split into sub-folders per topic.

ุชู…ุงุฑูŠู† ุงู„ุชุตู…ูŠู… ู…ุฎุฑุฌุงุชู‡ุง ุชุญู„ูŠู„ ุฃูˆ ู…ุฎุทุทุŒ ูˆู„ูŠุณุช ูƒูˆุฏุงู‹ ู‚ุงุจู„ุงู‹ ู„ู„ุชู†ููŠุฐ โ€” ุจูŠู†ู…ุง ุชู…ุงุฑูŠู† SQL (DDL, DML, DQLุŒ ุงู„ุฌูˆูŠู†ุฒุŒ ุงู„ุชุฌู…ูŠุนุŒ ุงู„ุงุณุชุนู„ุงู…ุงุช ุงู„ูุฑุนูŠุฉุŒ ุฅู„ุฎ) ูƒู„ู‡ุง ุชูู†ูุฐ ุจู†ูุณ ุงู„ุทุฑูŠู‚ุฉุŒ ูˆุบุงู„ุจู‹ุง ู…ุง ุชุฏู…ุฌ ุนุฏุฉ ู…ูˆุงุถูŠุน ููŠ ุงุณุชุนู„ุงู… ูˆุงุญุฏ. ู„ุฐู„ูƒ ุชู… ูุตู„ design/ุŒ ุจูŠู†ู…ุง ุจู‚ูŠุช ู…ูˆุงุถูŠุน SQL ู…ุณุทุญุฉ ุฏุงุฎู„ sql/ ุจุฏู„ุงู‹ ู…ู† ุชู‚ุณูŠู…ู‡ุง ุฅู„ู‰ ู…ุฌู„ุฏุงุช ูุฑุนูŠุฉ ู„ูƒู„ ู…ูˆุถูˆุน.


๐Ÿš€ Getting Started | ุงู„ุจุฏุก

Prerequisites | ุงู„ู…ุชุทู„ุจุงุช

  • A relational database installed โ€” PostgreSQL is used by default (Download)
  • ู‚ุงุนุฏุฉ ุจูŠุงู†ุงุช ุนู„ุงุฆู‚ูŠุฉ ู…ุซุจุชุฉ โ€” ูŠูุณุชุฎุฏู… PostgreSQL ุงูุชุฑุงุถูŠู‹ุง
psql --version

Running a SQL Problem | ุชุดุบูŠู„ ุชู…ุฑูŠู† SQL

# Clone the repository | ุงุณุชู†ุณุงุฎ ุงู„ู…ุณุชูˆุฏุน
git clone https://github.com/AbdullahNamespace/learn-database-by-practice.git
cd learn-database-by-practice

# Run a specific SQL problem against your database | ุชุดุบูŠู„ ุชู…ุฑูŠู† SQL ู…ุญุฏุฏ ุนู„ู‰ ู‚ุงุนุฏุฉ ุจูŠุงู†ุงุชูƒ
psql -U your_user -d your_database -f problems/sql/0001_create_simple_table/main.sql

Working on a Design Problem | ุงู„ุชุนุงู…ู„ ู…ุน ุชู…ุฑูŠู† ุชุตู…ูŠู…

Design problems don't execute โ€” open main.md, read the requirements, and write your analysis, normalized schema, or ER diagram directly in the file (or link an image/diagram file next to it).

ุชู…ุงุฑูŠู† ุงู„ุชุตู…ูŠู… ู„ุง ุชูู†ูุฐ โ€” ุงูุชุญ main.mdุŒ ุงู‚ุฑุฃ ุงู„ู…ุชุทู„ุจุงุชุŒ ูˆุงูƒุชุจ ุชุญู„ูŠู„ูƒ ุฃูˆ ุงู„ู…ุฎุทุท ุงู„ู…ุทุจู‘ุน ุฃูˆ ู…ุฎุทุท ER ู…ุจุงุดุฑุฉ ููŠ ุงู„ู…ู„ู (ุฃูˆ ุฃุถู ุฑุงุจุทุงู‹ ู„ุตูˆุฑุฉ/ู…ู„ู ู…ุฎุทุท ุจุฌุงู†ุจู‡).


๐Ÿ“ Problem Templates | ู‚ูˆุงู„ุจ ุงู„ุชู…ุงุฑูŠู†

This repo uses two templates, since design and SQL exercises are fundamentally different in nature: ูŠุณุชุฎุฏู… ู‡ุฐุง ุงู„ู…ุณุชูˆุฏุน ู‚ุงู„ุจูŠู†ุŒ ู„ุฃู† ุชู…ุงุฑูŠู† ุงู„ุชุตู…ูŠู… ูˆุชู…ุงุฑูŠู† SQL ู…ุฎุชู„ูุฉ ุฌูˆู‡ุฑูŠุงู‹ ููŠ ุทุจูŠุนุชู‡ุง:

  • template-design.md โ€” for design/analysis exercises (normalization, ER modeling, relationships) | ู„ุชู…ุงุฑูŠู† ุงู„ุชุตู…ูŠู…/ุงู„ุชุญู„ูŠู„
  • template-sql.sql โ€” for executable SQL exercises (DDL, DML, DQL, joins, etc.) | ู„ุชู…ุงุฑูŠู† SQL ุงู„ู‚ุงุจู„ุฉ ู„ู„ุชู†ููŠุฐ

See each file for the full format. | ุงู†ุธุฑ ุฅู„ู‰ ูƒู„ ู…ู„ู ู„ู…ุนุฑูุฉ ุงู„ุตูŠุบุฉ ุงู„ูƒุงู…ู„ุฉ.


Happy Learning! ๐Ÿ—„๏ธ | ุชุนู„ู‘ู… ุณุนูŠุฏ!

About

๐Ÿ—„๏ธ Learn Database by Practice

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors