| By Christoph Wienands | Article Rating: |
|
| November 8, 2006 12:00 PM EST | Reads: |
12,454 |
Figure 3 outlines the principal process of creating an update script:
- Build database v1.0 from source control (target database).
- Build database v2.0 from source control (source database).
- Synchronize the two databases and record the synchronization process as upgrade script.
- Generalize the automatically created upgrade script by rearranging and enhancing it with data transformations to prevent data loss.
- Most important: Verify your upgrade script by upgrading a new database v1.0 to v2.0. Use the database comparison function of your DB sync tool to test whether the upgraded DB is truly identical to the database v2.0 created straight from the repository.
The process of generalizing this specific upgrade script through enhancing and correcting will be more or less complicated, depending on how much guidance the synchronization tool provides. An excellent example for such guidance is shown in Figure 4, a screenshot taken from DbMaestro by Extreme. As you can see, the script is annotated with a number of warnings about potential data loss. Continuing our table rename example, such an annotated script would easily allow you to match the CREATE statement for table T2 and the DROP statement for table T1, and manually replace them with an sp_rename statement. In more complicated database changes like (de)normalizations and refactorings, you will actually need to create data transformations, e.g., through UPDATEs and INSERTs, and place them before any lossy schema changes.
Unfortunately, I'm not aware of any tool that currently recognizes operations, such as renames, and automatically creates the corresponding schema upgrade and data transformation operations. However, there are a number of best practices you can use to facilitate the process of creating a generalized upgrade script:
- During database development, check in often, preferably after each work item or refactoring step (just as when working with source code).
- Document the operations performed on each database revision, such as 'Normalized Table A into Table A and B' or 'Renamed Table C to D'. This will give better clues to the person generating the upgrade script.
- Rather than trying to create one huge upgrade script that spans dozens of revisions, create and concatenate multiple small upgrade scripts, each spanning only a few or even just one revision.
In this article I showed several techniques for addressing common problems in database development. A proper integration into source control is the foundation for any advanced technique such as concurrent development, testing, or creating upgrade scripts.
Prerequisite to each of these techniques is tool support (see the References section below). Speaking for myself, I have yet to find the perfect tool for all these tasks as each tool has its own strengths and weaknesses. Therefore, it might even make sense to work with two individual tools, depending on the tasks that you need to perform.
Lastly, I need to mention that for all the techniques described in this article I could only give a high-level introduction. Each one of them requires a certain amount of practice to use it efficiently, such as handling the check-out/check-in process confidently, consequently re-testing the build script before checking in, and getting an eye for manipulating automatically generated upgrade scripts. Nevertheless, you now should be on your way to establishing a reliable database change management process with predictable outcomes tailored to your own needs.
References
Published November 8, 2006 Reads 12,454
Copyright © 2006 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Christoph Wienands
Christoph Wienands is software engineer at Siemens Corporate Research, NJ. He received his Diplom-Informatiker (FH) at the University of Applied Sciences in Furtwangen, Germany. His current research activities include software factories, model-driven development, and domain-specific languages. Due to his research activities he is frequent speaker at conferences such as UML World and SD West.
- Kindle 2 vs Nook
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Infrastructure-as-a-Service Will Mature in 2010: Microsoft's David Chou
- Windows 7 – Microsoft’s First Step to the Cloud
- Cloud Expo and the End of Tech Recession
- Jill Tummler Singer, Deputy CIO of CIA, Keynotes at GovIT Expo
- Reality Check at the Cloud Computing Expo
- Visual Studio 2010 Is Cloud Friendly
- Fired SCO CEO Fires Back
- Kindle 2 vs Nook
- The Difference Between Web Hosting and Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- Wave on Ulitzer: Confessions of a Google Wave Fanboy
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Cloud Computing Best Practices
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Infrastructure-as-a-Service Will Mature in 2010: Microsoft's David Chou
- Eval JavaScript in a Global Context
- Windows 7 – Microsoft’s First Step to the Cloud
- Google Maps and ASP.NET
- Crystal Reports XI & How It Has Changed
- Converting VB6 to VB.NET, Part I
- Creating Controls for.NET Compact Framework in Visual Studio 2005
- Where Are RIA Technologies Headed in 2008?
- How to Write High-Performance C# Code
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Implementing Tab Navigation with ASP.NET 2.0
- i-Technology Photo Exclusive: Bill Gates & Steve Jobs In "Nerds"
- .NET Archives: Getting Reacquainted with the Father of C#
- i-Technology Viewpoint: "SOA Sucks"
- Programmatically Posting Data to ASP .NET Web Applications






























