Skip to content

DPriyangkush/SQL-Automation-Workflow-Project

Repository files navigation

SQL-Driven Data Workflow & Automation System

A complete end-to-end SQL automation project featuring stored procedures, views, CTE-based reports, indexing optimization, error handling, and automated data quality checks.

This project was designed to simulate a real enterprise SQL environmentβ€”similar to workflows used in banking, fintech, risk management, and data engineering teams.


πŸš€ Project Features

πŸ”Ή 1. Database Schema

  • customers
  • accounts
  • transactions
  • dq_log (Data Quality Log Table)

πŸ”Ή 2. Stored Procedures

  • add_transaction() β€” Validations + business logic + error handling
  • data_quality_check() β€” Automated DQ scan + logging

πŸ”Ή 3. Views

  • v_customer_overview β€” customer β†’ accounts β†’ transaction summary
  • v_high_value_accounts β€” accounts with high monthly volume

πŸ”Ή 4. CTE Reports

  • Monthly transaction summary
  • Last 30-day heavy activity

πŸ”Ή 5. Error Handling

  • TRY/CATCH
  • SIGNAL for validation
  • Logging failed quality checks

πŸ”Ή 6. Query Optimization

  • Before vs After EXPLAIN plans
  • Indexing strategies
  • Refactored nested queries

πŸ”Ή 7. Automation

  • MySQL Event Scheduler
  • Daily DQ job inserted into dq_log

πŸ—οΈ Project Structure

SQL-Data-Workflow-Automation/
│── schema.sql
│── sample_data.sql
│── views.sql
│── stored_procedures.sql
│── ctes.sql
│── automation_scripts.sql
│── optimization.sql
│── error_handling.sql
│── run_all.sh
│── assets/
β”‚   └── **All Screenshots**

🐳 Run the Project Using Docker

1. Start MySQL Container

docker run --name mysql-wf -e MYSQL_ROOT_PASSWORD=pass123 -p 3306:3306 -d mysql:8.0

2. Copy Project Files to Container

docker cp . mysql-wf:/sql/

3. Enter Container

docker exec -it mysql-wf bash

4. Run All SQL Scripts

cd /sql
chmod +x run_all.sh
./run_all.sh

πŸ“Έ Screenshots (Proof of Working System)

1. MySQL Workbench Connection

MySQL Workbench connection to Docker MySQL (127.0.0.1, port 3306)

2. SHOW DATABASES

Output showing sql_workflow database

3. Schema Expanded

Tables, Views, Stored Procedures visible under schema

4. SHOW TABLES

Screenshot showing: customers, accounts, transactions, dq_log

5. Table Previews

Customers

SELECT * FROM customers LIMIT 5;

Accounts

SELECT * FROM accounts LIMIT 5;

Transactions

SELECT * FROM transactions LIMIT 5;

6. View Outputs

v_customer_overview

View output showing customer overview

v_high_value_accounts

View output showing high value accounts

7. CTE Reports

Monthly Summary

CTE result showing account_id, total_credit, total_debit, txn_count

Last 30 Days

Heavy-activity CTE result

8. Stored Procedure Execution

Valid Transaction

CALL add_transaction(1, 500, 'credit', 'workbench-test')

Invalid Transaction (error handling)

ERROR 45000 – Invalid amount

9. Data Quality Automation

Running DQ Check

CALL data_quality_check() output

10. Query Optimization

Before Indexing (slow query)

EXPLAIN plan β€” high row count, no index used

After Indexing

EXPLAIN plan β€” using index, lower rows

SHOW INDEX

Index list output Index list output

11. Automation (Event Scheduler)

SHOW EVENTS FROM sql_workflow;

12. ER Diagram (Workbench Reverse Engineering)

ERD showing: customers β†’ accounts β†’ transactions


✨ Author

Priyangkush Debnath
SQL β€’ Data Engineering β€’ Backend Development β€’ Automation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages