0% found this document useful (0 votes)
4 views13 pages

Database Testing

Database Testing is essential for validating the schema, tables, triggers, and procedures in a database to ensure data integrity and application consistency. It encompasses various types of testing, including structural, data integrity, functional, transactional, performance, and security testing, and is crucial in sectors like banking and eCommerce. Best practices include validating schema after migrations, using parameterized queries, and automating repetitive tasks.

Uploaded by

rajarakesh19989
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views13 pages

Database Testing

Database Testing is essential for validating the schema, tables, triggers, and procedures in a database to ensure data integrity and application consistency. It encompasses various types of testing, including structural, data integrity, functional, transactional, performance, and security testing, and is crucial in sectors like banking and eCommerce. Best practices include validating schema after migrations, using parameterized queries, and automating repetitive tasks.

Uploaded by

rajarakesh19989
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Database Testing Cheat Sheet

1
── A Guide by Usman Qiass ──
What is Database Testing?

Database Testing validates the schema, tables,


triggers, and procedures in a database to ensure
data integrity and application consistency.

Why It Matters

● Ensures data accuracy & reliability


● Prevents data loss and corruption
● Validates backend changes during app updates

Where It's Used

● Banking apps, eCommerce, ERPs


● Any system relying on structured data storage

2
── A Guide by Usman Qiass ──
Types of Database Testing?

1. Structural Testing
2. Data Integrity Testing
3. Functional Testing
4. Transactional Testing
5. Performance Testing
6. Security Testing

3
── A Guide by Usman Qiass ──
1. Structural Testing

● Validates schema, tables, columns, indexes, and


relationships
● Ensures primary/foreign keys, constraints, and
data types are accurate
● Checks stored procedures, views, and triggers
for logic accuracy
● Helps identify structural mismatches after DB
migrations

Example
Ensure the users table has a NOT NULL constraint
on the email column and a foreign key to roles.

4
── A Guide by Usman Qiass ──
2. Data Integrity Testing

● Validates accuracy and consistency of data


across related tables
● Checks for orphan records, duplicate entries,
and NULL violations
● Ensures referential integrity between primary
and foreign keys
● Confirms valid default values and constraint
rules

Example
Verify that every order.customer_id exists in the
customers table and there are no NULL order_date
values.

5
── A Guide by Usman Qiass ──
3. Functional Testing

● Tests database behavior based on business logic


(CRUD operations)
● Verifies that front-end inputs correctly affect
back-end data
● Confirms stored procedures and functions
return expected outputs
● Ensures trigger actions are executed under
defined conditions

Example
When a new user signs up, their info should be
correctly inserted into the users table and an audit
trigger should log the event.

6
── A Guide by Usman Qiass ──
4. Transactional Testing

● Tests the ACID properties: Atomicity,


Consistency, Isolation, Durability
● Validates rollback and commit behavior during
transactions
● Checks concurrent access and transaction
isolation levels
● Ensures crash recovery does not corrupt data

Example
If a funds transfer fails midway, both debit and
credit transactions should rollback.

7
── A Guide by Usman Qiass ──
5. Performance Testing

● Measures execution time of complex queries and


transactions
● Identifies slow queries, indexing issues, and
bottlenecks
● Tests how the DB handles high-volume data and
concurrency
● Evaluates connection pool limits and caching
mechanisms

Example
A report query that normally runs in 2 seconds now
takes 15 seconds under load; indexing may be
required.

8
── A Guide by Usman Qiass ──
6. Security Testing

● Validates role-based access and permissions


(least privilege rule)
● Checks protection against SQL Injection and
data leaks
● Ensures data encryption at rest and in transit
● Verifies secure error handling and logging
practices

Example
Ensure normal users can't access admin-only tables
like salary_info, and that SQL injection attempts
are blocked.

9
── A Guide by Usman Qiass ──
Common DB Testing Scenarios

● Validate inserted data through UI/API


● Check referential integrity via foreign keys
● Compare actual data vs. expected in test cases
● Null/Not Null constraint validation
● Verify stored procedures with boundary values

Example
🧪 User registers via app → Check if the correct
record is inserted into Users table with the right
values

10
── A Guide by Usman Qiass ──
Tools & Queries for DB Testing

● SQL Server Management Studio (SSMS)


● Oracle SQL Developer
● DBeaver, Toad, pgAdmin
● Automation: Selenium + JDBC, Apache JMeter
(for DB load)

Common SQL for Testing:

Always backup test data before executing


destructive queries.

11
── A Guide by Usman Qiass ──
Best Practices & Checklist

✅ Test DB schema after every migration


✅ Validate test data before & after test execution
✅ Use parameterized queries to avoid SQL
injection
✅ Always isolate test data
✅ Automate repetitive queries

💡 Use database snapshots or transaction rollbacks


to maintain a clean test environment.

12
── A Guide by Usman Qiass ──
── A Guide By Usman Qiass ──

♻ Repost this if you learned something


new.

👉 Follow Usman Qiass for more QA insights,


testing tips, and real-world examples.

13
── A Guide by Usman Qiass ──

You might also like