# What needs checking when AI proposes a database schema?

Review an AI-generated database schema before using it. Follow a repair-shop example covering shared identities, constraints, migrations and recovery.

By Daltn editorial team. Published 2026-11-08.
Canonical: https://daltn.tech/feeds/reviewing-ai-generated-database-schemas/

## What needs checking when AI proposes a database schema?

Coding models can propose database tables and migrations, while the business still needs explicit relationships, ownership and change rules. Research results for Qwen2.5-Coder describe coding tasks rather than verified autonomous database design. Review generated structures with representative records, test corrections and migration recovery, and keep important changes under accountable human control.

## Keep these in mind

- A generated schema expresses assumptions about how the business works.
- Shared identities and enforced relationships need deliberate design.
- Test existing records and recovery before applying a migration.

## A schema decides which things the business can distinguish

A database schema defines tables, fields and relationships. Those decisions distinguish customers from orders, and proposed finishes from approved specifications.

A coding assistant can produce plausible table definitions quickly. The harder question is whether those definitions preserve the distinctions your colleagues need during corrections, reporting and handovers.

## Read coding results as evidence about coding tasks

The [Qwen2.5-Coder technical report](https://arxiv.org/abs/2409.12186), first submitted in September 2024, describes a family of code-focused models. Its evaluations concern defined coding capabilities and experimental setups.

These results make generated code worth evaluating. They do not establish that a model discovers every business rule or safely migrates a production database without review.

The model also needs current requirements. A new repair type or changed approval process can make an earlier schema incomplete. Treat generated code as an implementation proposal whose assumptions can be inspected.

## Model a repair shop with repeated visits

Consider an illustrative workshop where one customer brings two machines for repair. Each machine can return for a later job. A single combined table may duplicate identities and confuse the latest repair with an earlier visit.

Separate records can preserve those relationships. The owner must still decide which identifiers are stable and which information belongs to a particular visit.

Record | Identity or relationship | Question before accepting
--- | --- | ---
Customer | One account across visits | Can two similar names remain separate?
Machine | Identified item owned or serviced | Can ownership change without losing history?
Repair job | One visit linked to machine and customer | Do earlier jobs remain distinguishable?
Approval | Specific proposed work and decision | Which price and scope were accepted?

## Ask the database to enforce the relationship

[PostgreSQL’s constraints documentation](https://www.postgresql.org/docs/current/ddl-constraints.html) explains how foreign keys maintain references between related tables. Constraints can also express requirements such as uniqueness or required values.

These controls help prevent some invalid record states. They do not decide whether a customer identifier matches the right real person. The application still needs a clear matching process and an understandable correction path.

Ask the implementation team to demonstrate a rejected invalid insert. Also check an allowed correction, such as moving a misidentified machine to the proper customer without losing its repair history.

## A migration changes existing information, not only the diagram

A migration applies a schema change to a database. Adding a required field can fail when older records lack that value. Renaming a status can also affect reports or integrations that expect the previous name.

Test the proposed migration on a representative copy with appropriate privacy controls. Include empty fields, duplicates and older records created under previous rules. Compare important counts and relationships before and after the change.

Define recovery before approval. A reverse migration may not restore information already discarded by a destructive operation. Keep suitable backups and test the recovery procedure for the actual change.

## Evaluate the complete record journey

Try creating a customer, adding a repair, changing its scope and correcting a mistaken identity. Ask a colleague to explain the current state using ordinary application screens. A technically valid schema can still create confusing work.

Version the accepted schema and its business rules together. Future maintainers should understand why the structure exists and which examples it must continue to support.

1. Write the records and relationships in ordinary business language.
1. Review generated definitions against realistic correction cases.
1. Test constraints and migrations using representative existing data.
1. Approve the change only with a clear recovery and ownership plan.

## Common questions

### Can a schema be valid SQL and still be a poor business design?

Valid SQL can still combine distinct entities, duplicate identities or overwrite historical decisions. Test the records through ordinary changes and corrections. The design should support the questions colleagues need to answer after the original operator is unavailable.

### What should be reviewed before a database migration?

Check its effect on existing rows, constraints, reports and connected services. Test representative older records and define recovery for destructive changes. Record who approves the migration and who can restore the system if the result differs from expectations.

## Sources

- [Qwen2.5-Coder Technical Report](https://arxiv.org/abs/2409.12186): Supports the dated coding-model research; does not establish autonomous schema-design correctness.
- [PostgreSQL documentation: Constraints](https://www.postgresql.org/docs/current/ddl-constraints.html): Supports foreign keys, required fields and other database integrity controls.
