The Process Of Database Refactoring

January 2nd, 2012

You have learned in a vision of the method of data agile methodologies such as Agile Extreme Programming (XP) (Beck 2000) and DSDM (Stapleton 2003), an iterative and incremental software development. Application developers on Windows XP and DSDM projects often leave great design from the beginning (BDUF) approaches to emerging approaches in the design of a system evolves over the life of the project. In an agile development project final design is often not known until the application is ready for release. This is a very different way to work for many experienced professionals to work.

The implication is that the traditional approach of creating a (nearly) complete the logical data modeling and physical up front will not work. The main advantage of the traditional approach to making the task of the administrator of the database process (DBA) a lot easier – the basic pattern is to start early and that’s what people use. However, there are several disadvantages. First, we need designers to do things right, forcing most of the requirements identified above, even in the project, forcing the project team in a process of series development. Second, it does not support the change easily. As the project progresses, the project stakeholders need to understand what they will evolve, encouraging them to change their needs. The business environment will also change during the project, again to encourage their partners to their changing needs. In short, the traditional way of working, it does not work well in an agile environment. If Agile DBA will work and support project teams follow agile methodologies they need to find techniques that support iterative and incremental work. My experience is that the basic technique is the refactoring databases.

Table of Contents

1.Refactoring

Refactoring 2.Database
* Why is database refactoring?
* Preservation of the semantics
* Refactoring database
* What are

Database refactoring is difficult 3.Why

4.How to refactor your database
* Step 1: Start in your sandbox development
* Step 2: Put into practice in its integration litter (s)
* Step 3: Installation in production

5.Adopting refactoring databases in your organization

6.Database Best Refactoring practices

7.Database in the real world database

8.The refactorings catalog (published on another page)

1. Refactoring
Martin Fowler (1999) describes a programming technique called refactoring, a disciplined way to restructure the code. The basic idea is to make small changes to your code to improve its design, making it easier to understand and modify. Refactoring your code, you can develop slowly over time, to take an iterative and incremental programming. Site of Martin www.refactoring.com refactoring is a good resource online.

An essential aspect of a refactoring is that it preserves the semantics of the behavior of your code, at least from a perspective of black box. For example, there is a very simple refactoring called method to change the name, perhaps getPerson () to getPeople (). Although this change seems easy on the surface that has to do more to make this one change, you must also change every single invocation of this operation throughout the application code to invoke the new name. Once you have made these changes, then you can say that I really have redesigned their code, because it always works again as before.

It is important to understand that do not add functionality when refactoring. When refactoring existing code to improve, when you add the functionality to add a new code. Yes, you may need to refactor your existing code to add new features. Yes, you can find out later that you need to refactor the new code you just added. The point to note is that refactoring and adding new features are two different tasks, but complementary.

2. Refactoring database
In February 2002, software development describes a technique called refactoring I have given. This article describes my preliminary experiments in something that would be more appropriately have been called refactoring databases in retrospect. Hence the new name. From now on I will use refactoring code to refer to traditional refactoring as described by Fowler to distinguish it from refactoring databases.

Let’s start with some definitions. A basic refactoring is a simple change of a database schema that improves its design while retaining both its behavioral and semantic information. For the sake of this discussion a database schema includes both structural aspects such as definitions of tables and views as well as functional aspects, such as stored procedures and triggers. An interesting thing to note is that refactoring databases is conceptually more difficult than a refactoring of code, refactoring code is necessary to maintain the behavior semantics while database refactorings should preserve the semantics of information .

Refactoring is a database column called Split, one of several contained in a catalog database refactorings, which replaces a single-column table with two or more columns of others. For example, the work is on the table of the individual in its database and discovers that FirstData column is used for two different purposes – when the person is a client of this column stores the date of his birth and when the person is an employee that stores the date. Your request must now support those who can be both a client and an employee so you have a problem. Before you can implement this new requirement you need to repair your database schema by replacing the column with columns FirstData date of birth and HireDate. To maintain the semantics of the behavior of your database schema you need to update all the source code that has access to the column FirstData now working with two new columns. To maintain the semantics of the information you need to write a migration script that repeats itself across the table, determines the type and copy the current date in the appropriate column. While this sounds easy, and sometimes it is, my experience is that the database refactoring is very difficult in practice when cultural issues are taken into account (later).

2.1 Why Refactoring database?
There are two basic reasons why they should be interested in the database refactoring:

1.To ascertain the existing legacy databases. The conclusion is that the legacy databases are not going to correct, and that in terms of database refactoring is a safe and easy way to improve the information and database, quality time. My investigation in July 2006 in the current management of the data shows that 33% of organizations are, or intend to take an approach based on refactoring to meet existing data on the problems of production quality.

2.To support the evolutionary development. Modern processes of software development, such as RUP, XP and AUP, all work in an evolutionary process, if not agile. Professionals need to take technical data, including this one, they can work that way.

2.2 Preserving semantic
Semantic information refers to the meaning of information in the database from the perspective of the users of this information. To preserve the semantics of information implies that when you change the data values ​​stored in a column of the customer that the information should not be affected by the improvement. Similarly, with respect to the semantics of the behavior that the goal is to keep the black box functionality of it – the source code that works with the changed aspects of database schema should be revised to achieve the same functionality as before.

2.3 What database refactorings are not
A small change in the pattern of extension, such as adding a new column or table is a database refactoring because the change extends its design. Many small changes at the same time applies to your database, such as changing the name of ten columns, not to be considered a database refactoring because it is not a single change, small size. Database refactorings are small changes in the schema of your database to improve its design, the preservation of the semantics of behavior and information. That’s it. I have no doubt that you can make changes in their schema, and you can even follow a similar process, but they are database refactorings.

3. Why Database Refactoring is difficult
Pairing. As you learned in relational databases 101 coupling is a measure of dependency between two elements – the above two things together are more likely than a change in one will require a change in the other. The coupling is the “root of all evil”, when at the time of refactoring databases, plus the database schema with the more difficult it is to factor. Unfortunately, you have learned in the basic schemes 101 relational database relational database that are potentially near a wide variety of things:

* The source code of the application
* Another source of applications
* Source of data load
* Extract data from source
* The persistence frameworks / layers
* Your database schema
* Data migration scripts
* Test code
* Documentation


Share and Enjoy:
  • Digg
  • del.icio.us
  • IndianPad
  • StumbleUpon
  • Technorati
  • Yahoo! Buzz

Tags: , ,
Posted in Databases | Comments (0)

Leave a Reply

Categories

Archives