Use Case #15: Multi-Agent Schema Discovery
Using parallel agents to map an undocumented database schema across 200+ tables.
William Welsh
Author
Use Case #15: Multi-Agent Schema Discovery
Inherited a legacy system. 200+ tables. Zero documentation. The previous developer left no notes.
Time to do archaeology.
The Challenge
Understanding a database schema is slow work. You query table structures, trace foreign keys, look at sample data, infer relationships. At 10 minutes per table, that's 33 hours of tedious work.
The Multi-Agent Approach
I asked Claude to parallelize the discovery. It spawned 5 specialized agents running concurrently:
Agent 1: Structure Mapper - Extracted all table definitions, columns, data types, constraints. Pure schema information.
Agent 2: Relationship Tracer - Found all foreign keys, both explicit (constraints) and implicit (columns ending in _id that matched other table primary keys).
Agent 3: Data Sampler - Pulled sample rows from each table to understand actual data patterns. Found that some "required" columns were always null.
Agent 4: Naming Analyst - Analyzed naming conventions to group related tables. Found prefixes: auth_ (authentication), inv_ (inventory), ord_ (orders), rpt_ (reporting).
Agent 5: Usage Detector - Checked row counts and modification timestamps to identify active vs. dead tables. 47 tables had zero rows. 23 hadn't been modified in 2 years.
The Synthesis
After parallel discovery, Claude merged the findings. Generated a complete ERD (in Mermaid syntax), table-by-table documentation with inferred purposes, relationship map showing all connections, recommendations for cleanup (those 47 empty tables), and naming inconsistencies to fix.
Time Comparison
| Approach | Time |
|---|---|
| Manual discovery | ~33 hours |
| Single Claude session | ~6 hours |
| Multi-agent parallel | ~45 minutes |
The Real Win
The parallel agents found things I would have missed. Agent 4 noticed that some inv_ tables didn't follow the pattern - they were actually inventory snapshots, not inventory data. That distinction mattered for the migration.
Database archaeology from a legacy Rails app, December 2025.
William Welsh
Building AI-powered systems and sharing what I learn along the way. Founder at Tech Integration Labs.
Related Articles
View all →Use Case #6: Mock to Production Database
The app looked great but everything was fake. Claude created 20+ database tables, wrote RLS policies, generated seed data, and wired up real API calls.
Use Case #7: Document Synthesis
The discovery phase produced 10 separate documents totaling 400+ pages. Claude compiled them into one comprehensive PDF without losing critical details.
Use Case #14: RLS Policy Debugging
The query was correct. The data existed. But Supabase returned nothing. Claude traced it to a recursive RLS policy that created an infinite loop.