Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cyrus-M2/database-joins-repo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📊 Database Joins Repo

This project demonstrates various types of SQL joins using a sample PostgreSQL database. It's built for collaborative learning, hands-on practice, and clear demonstration of:

  • ✅ Table Aliases
  • ✅ Inner Joins
  • ✅ Left Joins
  • ✅ Full Outer Joins
  • ✅ Self Joins

🧰 Requirements

  • Python 3.10+
  • PostgreSQL installed and added to PATH (for windows users)
  • python-dotenv

Install dependencies:

python3 -m venv .venv
source .venv/bin/activate 
.venv/bin/python3 -m pip install -r requirements.txt
# or .venv\Scripts\activate on Windows

python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt

⚙️ Setup

1. Create a PostgreSQL Database

Create a new database manually or via psql:

CREATE DATABASE hospital_db

2. Configure .env

Create a .env file in the project root:

DB_NAME=hospital_db
DB_USER=your_postgres_user
DB_PASSWORD=your_postgres_password
DB_HOST=localhost
DB_PORT=5432

3. 📥 Load Data

Step 1: Create Schema

python data_loader/load_schema.py

# or  for linux users

python3 data_loader/load_schema.py

Step 2: Convert JSON → CSV (optional if CSVs are already generated)

python converter/convert_to_csv.py

Step 3: Load CSVs into PostgreSQL

python data_loader/run_copy_commands.py

# or for linux users
python3 data_loader/run_copy_commands.py

🧪 Sample Tables

  • doctors – Basic doctor details

  • hospitals – Used in joins

  • patients – For left/full joins

  • employees – Self join example via manager_id

🙌 Contributing

  1. Fork the repo

  2. Create your branch: git checkout -b feature/your-join-demo

  3. Make your changes

  4. Submit a pull request

👨‍💻 Contributors

🎉 Happy Coding Champ

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%