Skip to content

dibahadie/dbkala-ecommerce-database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DBKala Database Project

This repository contains the implementation of a database system for an e-commerce platform, developed as part of a Database Systems course project. The project is implemented using PostgreSQL and includes data integration, integrity constraints, analytical queries, triggers, views, and technical documentation written in Persian.


Project Features

  • Relational database schema for an online store
  • ETL pipeline using staging tables
  • Data cleaning and transformation
  • Enforcement of business rules using constraints and triggers
  • Advanced SQL analytical queries
  • Indexing for better performance
  • Views and reporting queries
  • Persian technical report written in LaTeX (XeLaTeX)

Technologies Used

  • Database: PostgreSQL
  • Query Language: SQL / PLpgSQL

Requirements

  • PostgreSQL 12+
  • psql client

Install on Ubuntu

sudo apt update
sudo apt install postgresql postgresql-client texlive-xetex

Setup

1. Create Database

createdb dbkala

2. Run SQL Files

From terminal:

psql dbkala -f sql/01_load_branches_suppliers_products.sql

Or inside psql:

psql dbkala
\i sql/01_load_branches_suppliers_products.sql

Run scripts in this order:

  1. Data loading
  2. Constraints
  3. Queries
  4. Views

Data Import Example

Inside psql:

\copy stg_bdbkala_full FROM 'dataset/BDBKala_full.csv' CSV HEADER;

Main Components

ETL Process

  • Load CSV files into staging tables
  • Convert text fields to correct types
  • Generate internal IDs
  • Populate core tables

Constraints & Triggers

  • Email validation
  • Discount limits
  • Order/delivery date checks
  • Status transitions
  • Wallet debt limit
  • Packaging restrictions
  • Return validation
  • Feedback validation

Analytical Queries

Includes:

  • Average profit by category
  • Popular products
  • Valuable customers
  • Category association
  • Delivery delay detection
  • VAT calculation
  • Wallet turnover
  • BNPL eligibility
  • Supplier ranking
  • Customer lifetime value
  • JSON attribute analysis

About

Implementing an e-commerce platform schema, data loading, constraints, analytical queries, and reports using PostgreSQL.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors