Notes on <<Refactoring Databases - Evolutionary Database Design>>

Notes on <<Refactoring Databases - Evolutionary Database Design>> (written by Scott W. Ambler and Pramod J. Sadalage). 

 

Forward 

After skimming through the book, I found it would be like nothing had ever happened if I dont take down some notes here :-(

 

"Refactoring" is not new to developers, I think. Even though I didn't read any book on this subject (what a shame), I heard a lot about "refactoring" during the daily work. Perhapse, the most famous book on "refactoring" is the one written by Martin Fowler -- <<Refactoring:Improving the Design of Existing Code>>. 

Though "refactoring" seems to be quite "natural" during the software development nowdays, the "database refactoring" is not so widely talked about and accepted by database developers. Fortunately, the book <<Refactoring Databases>> takes the lead in expand "refactoring" to database realm.

 

What this book impressed me most is not those refactoring strategies, it's that we may not be able to push the "refactoring" into production immediately as there may be serveral application are running on top of the database which are not afforable for shutting down at that time. Instead, we need to work out a appropriate "transition period" and keep the "old" and "new" implementation stay online until the "transition" end and remove the "old" implementation on the due date. 

Like the "code smell" mentioned in the refactoring book, this book also lists out some "database smells" which are popular database schema design issues. 

 

Personally, I think the Chapter 5 is the best.

Book Overview


So, what's database refactoring?

A database refactoring is a small change to your database schema which improves its design without changing its semantics (e.g. you don't add anything new in function nor do you break anyging).

The process of database refactoring is the evolutionary improvement of your database schema so as to improve your ability to support the new needs of your custtomers, support evolutionary software development, and to fix existing legacyh database design problems.

 

The book describes database refactoring from the point of view of...

(1) Technology

It includes source code for how to implement each refactoring strategy. 

(2) Process

It describes in detail the process of database refactoring in both simple (single application on top of the db) and complex situation (many application on top of the same db). 

(3) Culture

Culture challenges within your organization will likely prove to be the most difficult hurdle to overcome

 

Contents of the Book

There are 11 chapters in total in this book which is orginzed into two sections:

(1) Evolutionary database development and database refactoring

(2) Databse refactoring reference catalog.

 

 Each refactoring strategy includes the following sections...

- Motivation: why you want to refactor the db?

- Potential Tradeoffs: the potential risk brought by the refactoring

- Schema Update Mechanics : steps to carry out the refactoring

- Data-Migration Mechanics: whether need to do some data migration because of the refactoring?

- Access Program Update Mechanics: whether the external system needs to be updated?

 

Every time to apply the refectory strategy, you need to bear in mind those things to make sure the "refactoring" runs smoothly. 

 

Chapter List:

Chapter 1:  Evolutionary Database Development

(1) Database refactoring

(2) Evolutionary database modeling

(3) Database Regression Testing

(4) Configuration Management of Database Artifacts

(5) Devloper Sandboxes

(6) Impediments to Evolutionary Database Development Techniques

Chapter 2: Database Refactoring

(1) Database Smells

- Multipurpose column

- Multipurpose table

- Redundant data

- Tables with too many columns

- Tables with too many rows

- "Smart" columns

- Fear of Change

 

Chapter 3: The Process of Database Refactoring

(1) Verify that a Databaase Refactoring is Appropriate

(2) Choose the Most Appropriate Database Refactoring

(3) Deprecate the Original Database Schema

(4) Test Before, During, and After

(5) Modify the Database Schema

(6) Migrate the Source Data

(7) Refactor External Access Program(s)

(8) Run Your Regression Tests

(9) Version Control Your Work

(10) Announce the Refactoring

 

Chapter 4: Delopying Into Production

(1) Effectively Deploying Between Sandboxes

(2) Applying Bundles of Database Refactoring

(3) Scheduling Deployement Window

(4) Deploying your System

(5) Removing Deprectated Schema

 

Chapter 5: Database Refactoring Strategies

(1) Smaller changes are eaiser to apply

(2) Uniquely Identify Individual Refactoring

(3) Implement a Large Change by Many Small Ones

(4) Have a Database Configuration Table

(5) Prefer Trigger Over Views or Batch Synchronization

(6) Choose a Sufficient Transition Period

(7) Simplify your database Change Control Board (CCB) Strategy

(8) Simply Negotiations with Other Teams

(9) Encapsulate Database Access

(10) Be Able to Easily Set Up a Database Environment

(11) Do Not Duplicate SQL

(12) Put Database Assets Under Change Control

(13) Beware of Politics

 

Chapter 6: Structural Refactorings

(1) Drop Column

(2) Drop Table

(3) Drop View

(4) Introduce Calculated Column

(5) Introduce Surrogate Key

(6) Merge Columns

(7) Merge Tables

(8) Move Column

(9) Rename Column

(10) Rename Table

(11) Rename View

(12) Replace LOB with Table

(13) Replace Column

(14) Replace One-To-Many With Associate Table

(15) Replace Surrogate Key With Natural Key

(16) Split Column

(17) Split Table

 

Chapter 7: Data Quality Refactorings

(1) Add Lookup Table

(2) Add Standard Codes

(3) Add Standard Type

(4) Consolidate Key Strategy

(5) Drop Column Constraint

(6) Drop Default Value

(7) Drop Non-Nullable

(8) Introduce Column Constraint

(9) Introduce Column Format

(10) Introduce Default Value

(11) Make Column Non-Nullable

(12) Move Data

(13) Replace Type Code With Property Flags

 

Chapter 8: Referential Integrity Refactorings

(1) Add Foreign Key Constriant

(2) Add Trigger For Calculated Column

(3) Drop Foreign Key Constraint

(4) Introduce Cascading Delete

(5) Introduce Hard Delete

(6) Introduce Soft Delete

(7) Introduce Trigger For History

 

Chapter 9: Architectural Refactorings

(1) Add CRUD Methods

(2) Add Mirror Table

(3) Add Read Method

(4) Encapsulate Table With View

(5) Introduce Calculation Method

(6) Introduce Index

(7) Introduce Read-Only Table

(8) Migrate Method From Database

(9) Migrate Method To Database

(10) Replace Method(s) With View

(11) Replace View With Method(s)

(12) Use Offcial Data Source

 

Chapter 10: Method Refactorings

(1) Interface Changing Refactoring

- Add Parameter

- Parameterize Method

- Remove Parameter

- Remove Method

- Reorder Parameters

- Replace Parameter with Explicit Methods

(2) Internal Refactoring

- Consolidate Conditional Expression

- Decompose Conditional

- Extract Method

- Introduce Variable

- Remove Control Flag

- Remove Middle Man

- Rename Parameter

- Replace Literal with Table Lookup

- Replace Nested Conditional with Guard Clauses

- Split Temporary Variable

- Substitute Algorithm

 

Chapter 11: Transformings 

(1) Insert Data

(2) Introduce New Column

(3) Introduce New Table

(4) Introduce View

(5) Update Data

 

 

转载于:https://www.cnblogs.com/fangwenyu/archive/2012/03/10/2370556.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值