Skip to content

A hands-on SQL practice repository focused on mastering JOIN operations using the MySQL World database. Includes real-world queries combining country, city, and countrylanguage tables to build strong relational querying skills.

Notifications You must be signed in to change notification settings

datascientistshorya/sql-join-practice-on-world-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

🌍 SQL JOIN Practice on World Database

A hands-on SQL practice project to master JOINs using the classic MySQL World sample database. This repository is designed for beginners to intermediate learners who want to build strong relational database querying skills.

📌 About This Repository

This repo contains:

✅ world.sql → The complete World database ✅ joins.sql → 20 solved JOIN queries (Basic → Advanced)

By working through these queries, you will learn how to combine data from multiple tables and answer real-world questions using SQL.

🧠 What You’ll Learn

How relational databases connect tables

How JOINs work in SQL

Writing real-world analytical queries

Using aggregation with JOINs

Subqueries with JOINs

Grouping and filtering joined data

🗂️ World Database Structure

The World database contains 3 main tables:

1️⃣ Country

Stores country-level information

Code (Primary Key)

Name

Continent

Population

Capital (links to City.ID)

2️⃣ City

Stores city-level information

ID (Primary Key)

Name

CountryCode (Foreign Key → Country.Code)

District

Population

3️⃣ CountryLanguage

Stores languages spoken in countries

CountryCode (FK → Country.Code)

Language

IsOfficial (T/F)

Percentage spoken

⚙️ How to Import the Database Option 1 — MySQL Workbench (Recommended)

Open MySQL Workbench

Connect to your database server

Go to File → Open SQL Script

Open world.sql

Click Execute (⚡)

Refresh schemas — the world database will appear

Option 2 — Command Line mysql -u your_username -p < world.sql

Then:

USE world;

You’re ready to practice!

🔍 What is a JOIN?

A JOIN combines rows from two or more tables based on a related column.

Example SELECT city.Name, country.Name FROM city JOIN country ON city.CountryCode = country.Code;

This works because:

City.CountryCode links to

Country.Code

🧪 Practice Levels 🟢 Basic

Simple INNER JOINs

Matching foreign keys

Filtering joined data

🟡 Intermediate

GROUP BY with JOINs

Aggregations (COUNT, SUM, AVG)

HAVING clause

Subqueries

🔴 Advanced Concepts Covered

Circular relationships (capital city link)

Largest city vs capital city comparisons

Majority language analysis

District diversity per country

🚀 How to Use This Repo

Import world.sql

Open joins.sql

Run each query

Modify queries and experiment

Try writing your own versions

💡 Who Is This For?

SQL beginners

Data analytics learners

Students preparing for interviews

Anyone practicing relational databases

⭐ Pro Tip

Don’t just run queries — try to rewrite them yourself. Practice turning questions into SQL logic.

📬 Feedback & Contributions

https://www.linkedin.com/in/shorya-bisht-a20144349/

Feel free to fork, improve, or add more practice questions!

Happy Querying! 🚀

About

A hands-on SQL practice repository focused on mastering JOIN operations using the MySQL World database. Includes real-world queries combining country, city, and countrylanguage tables to build strong relational querying skills.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published