https://github.com/harmain-ali/postgre-sql-for-data-science
https://github.com/harmain-ali/postgre-sql-for-data-science
dataanalytics database database-design database-management datascience dataset postgres postgresql postgresql-database postgressql sql sqlite
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/harmain-ali/postgre-sql-for-data-science
- Owner: Harmain-Ali
- License: mit
- Created: 2025-07-17T15:23:48.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-02T12:36:35.000Z (11 months ago)
- Last Synced: 2025-08-02T14:32:20.988Z (11 months ago)
- Topics: dataanalytics, database, database-design, database-management, datascience, dataset, postgres, postgresql, postgresql-database, postgressql, sql, sqlite
- Language: Jupyter Notebook
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## π PostgreSQL Cheatsheet β From Zero to Hero π





## π₯ Whatβs Inside?
This repo is your **ultimate PostgreSQL cheatsheet**, carefully crafted to take you from **absolute beginner β advanced SQL master**.
* β
Complete **PostgreSQL Cheatsheet** with theory + SQL queries + pgAdmin steps
* β
Covers **0 β Hero topics** (Databases, Tables, Queries, Joins, Subqueries, Functions, Views, Indexes, Transactions, Security, and more)
* β
A **sample database (dvdrental)** with **150+ solved real-world questions** for practice
* β
Perfect for **Data Scientists, Analysts, and Developers**
## ποΈ Topics Covered
* Database Creation & Connections
* Tables (Create, Modify, Drop)
* Data Insertion, Import & Export
* Filtering (WHERE, IN, BETWEEN, LIKE)
* Sorting & Limiting
* Aggregations & GROUP BY
* Joins (INNER, LEFT, RIGHT, FULL, CROSS)
* Subqueries & CTEs (WITH)
* Views & Materialized Views
* Functions, Procedures & Triggers
* Window Functions
* Indexes & Performance Optimization
* Transactions & Concurrency Control
* Security & User Management
* Connecting PostgreSQL with Python (psycopg2 & SQLAlchemy)
## π Sample Practice Questions
β **Basic SELECT Queries** β List all customers, find films longer than 100 mins, display rentals on a given date
β **Filtering** β Customers from London, films with rental rate between 2β5, NULL checks
β **Sorting & Limiting** β Top 10 expensive films, earliest rentals, most recent payments
β **Joins** β Films with categories, customers with city names, rentals with staff names
β **Aggregations** β Count films, calculate average payments, revenue per store
β **Subqueries** β Most rented film, top customers, films longer than average
β **Complex Joins** β Top 5 customers by rentals, total revenue per country, least rented film
π More than **150+ solved examples** included using **dvdrental** database.
## π How to Use
1. Clone the repo
```bash
git clone https://github.com/your-username/postgresql-cheatsheet.git
cd postgresql-cheatsheet
```
2. Import the sample **dvdrental** database into PostgreSQL.
3. Explore `postgre_sql_cheatsheat.ipynb` for theory + queries.
4. Try solving practice questions (`DVD-RENTAL-PRACTICE-QUESTIONS.txt`) in your own database.
## π Related Resources
Expand your learning beyond PostgreSQL:
* π [EDA Guide (Exploratory Data Analysis)](https://github.com/Harmain-Ali/Complete-EDA-Guide)
* π [SQLAlchemy Cheatsheet](https://github.com/Harmain-Ali/SQLAlchemy-For-DataScience)
## π Support
If you find this helpful:
* β **Star this repo** to support my work
* π€ **Follow me** for more data science & SQL content
* π Stay tuned for upcoming **Pandas Cheatsheet** & more advanced guides
## π·οΈ Tags
`postgresql` `sql` `cheatsheet` `database` `data-science` `joins` `queries` `data-analysis` `sqlalchemy` `pgadmin` `practice-questions` `dvdrental`
β‘ With this guide, youβll go from **writing your first SELECT query** β **mastering window functions, joins, optimization, and real-world analysis**.