Database refactoring
A database refactoring is a simple change to a database schema that improves its design while retaining both its behavioral and informational semantics[1]. Database refactoring does not change the way data is interpreted or used and does not fix bugs or add new functionality. Every refactoring to a database leaves the system in a working state, thus not causing maintenance lags, provided the meaningful data exists in the production environment.
A database refactoring is conceptually more difficult than a code refactoring; code refactorings only need to maintain behavioral semantics while database refactorings also must maintain informational semantics.
Database refactorings are often motivated by the desire for database normalization of an existing production database, typically to "clean up" the design of the database. Examples of database refactoring:
- Splitting an aggregate table into two different tables in the process of .
- Renaming an existing column to make its purpose clearer.
- Combining two columns into a single one because they were being used for the same purpose.
- Splitting an existing column into two or more columns because the original column was being used for several purposes (so you have one column per purpose).
Process of Database Refactoring
The process of database refactoring is the act of applying database refactorings to evolve an existing database schema (database refactoring is a core practice of evolutionary database design). You refactor a database schema for one of several reasons:
- To develop the schema in an evolutionary manner in parallel with the evolutionary design of the rest of your system.
- To fix design problems with an existing legacy database schema[2].
- To implement what would be a large (and potentially risk) change as a series of small, low-risk changes.
Tools
See also
References
- ^ Scott Ambler and Pramod Sadalage (2006). Refactoring databases: Evolutionary database design. Addison-Wesley. ISBN 978-0-321-29353-4
- ^ "Database Schema". Retrieved 15 September 2015.
External links
- Database refactoring presentation at InfoQ.com by Scott W. Ambler
- The Process of Database Refactoring by Scott W. Ambler
- Catalog of Database Refactorings. by Scott W. Ambler.
- Database Refactoring Website by Pramod Sadalage