Jump to content

Database refactoring

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by ScottWAmbler (talk | contribs) at 15:33, 25 July 2019 (Refactored the description to increase its readability and to add the examples of database refactorings). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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:

  1. To develop the schema in an evolutionary manner in parallel with the evolutionary design of the rest of your system.
  2. To fix design problems with an existing legacy database schema[2].
  3. To implement what would be a large (and potentially risk) change as a series of small, low-risk changes.


Tools

See also

References

  1. ^ Scott Ambler and Pramod Sadalage (2006). Refactoring databases: Evolutionary database design. Addison-Wesley. ISBN 978-0-321-29353-4
  2. ^ "Database Schema". Retrieved 15 September 2015.