The Agile Data (AD) Method

Agile Data Logo

Catalog of Database Refactorings: Referential Integrity Refactorings

A referential integrity database refactoring is a change which ensures that a referenced row exists within another table and/or that ensures that a row which is no longer needed is removed appropriately so as to improve your database design without changing its semantics.
Refactoring Example
Add Foreign Key Constraint. Add a foreign key constraint to an existing table to enforce a relationship to another table.


Add Trigger For Calculated Column. Introduce a new trigger to update the value contained in a calculated column.


Drop Foreign Key Constraint. Remove a foreign key constraint from an existing table so that a relationship to another table is no longer enforced by the database.


Introduce Cascading Delete. Ensure that the database automatically deletes the appropriate “child records” when a “parent record” is deleted.


Introduce Hard Delete. Remove an existing column which indicates that a row has been deleted and instead actually delete the row.


Introduce Soft Delete. Introduce a flag to an existing table which indicates that a row has been deleted instead of actually deleting the row.


Introduce Trigger for History. Introduce a new trigger to capture data changes for historical or audit purposes.



Database refactorings
This book describes, in detail, how to refactor a database schema to improve its design. The first section of the book overviews the fundamentals evolutionary database techniques in general and of database refactoring in detail. More importantly it presents strategies for implementing and deploying database refactorings, in the context of both “simple” single application databases and in “complex” multi-application databases. The second section, the majority of the book, is a database refactoring reference catalog. It describes over 60 database refactorings, presenting data models overviewing each refactoring and the code to implement it.


Recommended Reading

Choose Your WoW! 2nd Edition
This book, Choose Your WoW! A Disciplined Agile Approach to Optimizing Your Way of Working (WoW) – Second Edition, is an indispensable guide for agile coaches and practitioners. It overviews key aspects of the Disciplined Agile® (DA™) tool kit. Hundreds of organizations around the world have already benefited from DA, which is the only comprehensive tool kit available for guidance on building high-performance agile teams and optimizing your WoW. As a hybrid of the leading agile, lean, and traditional approaches, DA provides hundreds of strategies to help you make better decisions within your agile teams, balancing self-organization with the realities and constraints of your unique enterprise context.


I also maintain an agile database books page which overviews many books you will find interesting.