Skip to content

ChandeDeVargas/sql_for_qa_testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SQL for QA Testing

MySQL SQL

A comprehensive SQL query collection focused on data quality validation and bug detection in databases. This project demonstrates real-world QA skills: finding data anomalies, validating integrity, and detecting broken relationships.


🎯 Project Purpose

This repository showcases SQL skills from a QA Engineer perspective:

  • βœ… Detecting invalid data (negative values, nulls, zeros)
  • βœ… Finding duplicates and inconsistencies
  • βœ… Validating data integrity and relationships
  • βœ… Identifying orphaned records and broken references

This is NOT about writing complex queries to show off.
This IS about writing clear, focused queries that find real bugs.


πŸ—„οΈ Database Schema

Simple e-commerce database with intentional bugs for QA practice:

Tables:

  • users - Customer accounts
  • products - Product catalog
  • orders - Purchase orders

Relationships:

orders.user_id    β†’ users.id
orders.product_id β†’ products.id

πŸ› Intentional Bugs in Dataset

The seed data contains real-world bugs that QA engineers encounter:

Data Quality Issues:

  • Negative totals and prices
  • Zero prices and quantities
  • Invalid/future dates
  • Empty/null required fields

Duplicates:

  • Duplicate emails in users
  • Potential duplicate orders

Data Integrity:

  • Orphaned orders (user doesn't exist)
  • Broken references (product doesn't exist)
  • Totals that don't match calculations

πŸ“‚ Project Structure

sql-for-qa-testing/
β”œβ”€β”€ schema/
β”‚   └── schema.sql              # Database structure (simple & clear)
β”œβ”€β”€ data/
β”‚   └── seed_data.sql           # Test data with intentional bugs
β”œβ”€β”€ queries/
β”‚   β”œβ”€β”€ 01_basic_queries.sql    # Simple filters and aggregations
β”‚   β”œβ”€β”€ 02_joins.sql            # Find missing relationships
β”‚   └── 03_edge_cases.sql       # Real-world scenarios
β”œβ”€β”€ results/
β”‚   └── bug_findings.md         # Document what you found
└── README.md

πŸš€ Getting Started

Prerequisites

  • MySQL 8.0+
  • MySQL Workbench (or any SQL client)

Setup

  1. Create database:
   CREATE DATABASE sql_qa_testing;
   USE sql_qa_testing;
  1. Run schema:
   mysql -u root -p sql_qa_testing < schema/schema.sql
  1. Load test data:
   mysql -u root -p sql_qa_testing < data/seed_data.sql
  1. Start finding bugs:
   source queries/01_basic_queries.sql

πŸ§ͺ Running Queries

Each query file is standalone and can be executed independently:

-- Example: Find negative prices
source queries/02_data_quality/find_negative_totals.sql

Or open in MySQL Workbench and execute.


πŸ“Š What You'll Learn

As a QA Engineer:

  • How to validate data quality systematically
  • Writing queries that detect real bugs
  • Understanding data relationships and integrity
  • Identifying edge cases in datasets

Technical Skills:

  • SQL SELECT with filters and joins
  • Aggregate functions for validation
  • Subqueries for data verification
  • NULL handling and data anomalies

πŸŽ“ Query Philosophy

Good QA SQL queries are:

  • βœ… Clear - Easy to understand what's being checked
  • βœ… Focused - One validation per query
  • βœ… Documented - Comments explain the bug being detected
  • βœ… Actionable - Results can be directly reported

Avoid:

  • ❌ Overly complex queries that are hard to maintain
  • ❌ Multiple validations in one query
  • ❌ Queries without clear purpose

πŸ“Š Project Status

Category Status Queries
Basic Validation βœ… Complete 3/3
Data Quality βœ… Complete 4/4
Duplicates βœ… Complete 3/3
Data Integrity βœ… Complete 3/3

Total: 13 professional QA queries

πŸ› Bugs Found

This project successfully detected:

  • 3 orders with invalid totals (negative/zero)
  • 2 records with future dates
  • 3 products with zero/negative prices
  • 1 user with empty name
  • 2 duplicate emails (4 users affected)
  • 1 orphaned order (user doesn't exist)
  • 1 broken reference (product doesn't exist)

πŸŽ“ Learning Outcomes

QA Thinking:

  • βœ… How to approach data validation systematically
  • βœ… What questions to ask about data integrity
  • βœ… How to prioritize which checks matter most
  • βœ… Writing queries that find real bugs

SQL Skills:

  • βœ… Basic SELECT with meaningful WHERE clauses
  • βœ… JOINs to detect missing relationships
  • βœ… Aggregations (COUNT, SUM) for validation
  • βœ… NULL handling (IS NULL, COALESCE)

Not Covered (Intentionally):

  • βœ… Window functions (RANK, LAG) for pattern detection
  • βœ… Common Table Expressions (CTEs) for readable logic
  • βœ… Stored Procedures for automated validation
  • βœ… Database Views for data abstraction

Why? Professional QA Automation requires scalable and maintainable code. By using Views and Procedures, we centralize validation logic and eliminate redundant queries.

Data Integrity: 86.67% (13 out of 15 orders are valid)

🀝 Contributing

This is a personal learning project, but suggestions are welcome!


πŸ‘€ Author


πŸ“„ License

This project is open source and available under the MIT License.


⭐ If this project helps you learn SQL for QA, give it a star!

About

I practice with SQL or MySQL for QA testing, improving database testing skilss, including negative tests, intentional tests, valid tests, etc.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors