Prompt·Workflows·DBR03

Simplify a crowded schema

Fewer objects with the same outcomes.

Markdown
Prompt
Simplify a crowded schema Fewer objects with the same outcomes.
Work through this in order and check in with me after each step. Stay read-only until I approve a change.

1. Start: Inventory objects and their real consumers.

Which database objects no longer earn their keep? (PG10)
Examine the tables, views, functions, triggers, indexes and materialized views in this database. Identify redundant representations, obsolete objects, overlapping responsibilities, unnecessary dependency chains and abstractions that no longer provide meaningful value. Verify actual consumers before recommending removal. Rank opportunities by complexity eliminated, operational savings and migration risk.

2. If needed: PG11 for copies of the same fact; PG12 for confusing names; PG17 before any schema change ships.

Are we storing the same truth multiple times? (PG11)
Find concepts and values maintained in multiple tables, materialized views, caches or derived columns. Trace which representation is authoritative, why each copy exists, how it stays synchronized, and what happens when the copies disagree. Recommend which duplication is justified by performance or history and which should be removed.

Can the schema be easier to understand without losing depth? (PG12)
Review the database's logical organization from the perspective of a new senior engineer. Identify confusing names, mixed responsibilities, inconsistent conventions, unclear relationships and schemas that obscure the business domain. Recommend structural improvements that make the model easier to understand and maintain without sacrificing useful historical detail or creating unnecessary migrations.

Are our database changes safe before we merge? (PG17)
Review this database change against the live schema, existing consumers, prior migrations and deployment process. Establish whether it preserves current records, supports old and new application versions during rollout, and can be verified on an isolated database. Identify the smallest necessary migration and a realistic recovery path before approving it.

3. Change: Confirm consumers before retiring anything, and keep old and new versions working during rollout.

4. Done when: Less complexity with unchanged results for users and data.

Related prompts

More in Workflows.