Sunday, March 8, 2009

Refactoring Databases: Evolutionary Database Design

Refactoring Databases: Evolutionary Database DesignPramod Sadalage gave a talk about refactoring databases. He starts by stating that business requirements change all the time and with agile practice we are getting better at embracing these changes, but that we must also get better at managing change at the database level. He then covers some recommendations to make database refactoring possible:

1. Version Control Database Assets: Having these in version control provides greater control over changes, couples databases and applications, integrate in version control instead of database.

2. Swap best practices: educate DBA about coding practices, educate developers about SQL, automate tasks (physical table deployment, usage statistics, schema verification, data migration verification)

3. Give everyone a sandbox: each developer has his own copy of the database. Have a script to create a database, create all the tables, views, etc, insert seed data and test data. Use dbdeploy tool.

4. Continues Integration: Since sql script is in version control, then it can also be part of continues integration. Migration scripts always get tested.

5. Scaffolding: The old and new schema work together until all apps have been migrated to use the new schema

6. Controlled Release: merge all deltas into release script, branch sql script with code

7. Assert Database Behavior: test the database behavior. Check for unique indexes, nulls, other constraints

This presentation is available on InfoQ at