Use Case Guides

Testing & Development

Testing & Development

One of WhoDB's most powerful features for developers is the ability to generate realistic mock data and quickly test database interactions. Whether you're writing integration tests, developing new features, or debugging database issues, WhoDB streamlines your testing workflows.

Development Database Workflow

Setting Up Your Development Database

Generating Mock Data

The Mock Data Generator

WhoDB includes a powerful mock data generator for creating test datasets:

Mock Data Generation Patterns

Pattern 1: Bootstrap a Complete Schema

For a brand new feature, populate all related tables at once:

Pattern 2: Test Specific Scenarios

Generate data that exercises particular code paths:

Example: Testing discount code functionality
1. Generate 50 users (append)
2. Generate 30 orders with various amounts
3. Generate 5 different discount codes
4. Manually update some orders to use discount codes
5. Test your discount logic against this dataset

Use a mix of generated data and manual entries for edge cases.

Pattern 3: Reproduce Production Issues

When debugging production issues locally:

Testing Workflows

Workflow 1: Unit Testing with Mock Data

When writing unit tests that interact with a database:

Workflow 2: Integration Testing

When testing how multiple components interact:

Workflow 3: Performance Testing

When optimizing queries or testing with large datasets:

Query Testing and Debugging

Testing Query Logic

When writing complex queries, test them iteratively:

Debugging Failing Queries

When a query doesn't return what you expect:

Development Workflows with Mock Data

Workflow: Feature Development Cycle

Query Examples for Common Development Tasks

Monitoring and Debugging

sql

-- Recent errors logged
SELECT * FROM error_logs
ORDER BY created_at DESC
LIMIT 20;

-- Failed transactions
SELECT * FROM transactions
WHERE status = 'failed'
AND created_at > NOW() - INTERVAL '1 hour'
ORDER BY created_at DESC;

-- Database activity by table
SELECT table_name, COUNT(*) as activity_count
FROM audit_log
WHERE created_at > NOW() - INTERVAL '1 hour'
GROUP BY table_name
ORDER BY activity_count DESC;

Data Validation

sql

-- Orphaned records (foreign key violations)
SELECT o.id FROM orders o
LEFT JOIN users u ON o.user_id = u.id
WHERE u.id IS NULL;

-- Duplicate entries
SELECT email, COUNT(*) as cnt
FROM users
GROUP BY email
HAVING COUNT(*) > 1;

-- Data freshness
SELECT table_name, MAX(created_at) as last_record
FROM audit_log
GROUP BY table_name
ORDER BY last_record;

Performance Investigation

sql

-- Slowest queries in history
SELECT query, avg_execution_time, execution_count
FROM query_log
ORDER BY avg_execution_time DESC
LIMIT 20;

-- Table sizes and row counts
SELECT table_name, row_count, size_mb
FROM table_stats
ORDER BY size_mb DESC;

-- Most-accessed tables
SELECT table_name, access_count
FROM table_access_stats
ORDER BY access_count DESC;

Best Practices for Development Testing

Next Steps

Ready to advance your development practices?

Database Exploration

Learn how to explore unfamiliar databases

Data Analysis

Use WhoDB for advanced data analysis

Query Interface

Master advanced SQL techniques

Export Options

Learn comprehensive export capabilities