30.06.2013 Views

SQL Server Team-based Development - Red Gate Software

SQL Server Team-based Development - Red Gate Software

SQL Server Team-based Development - Red Gate Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 3: Change Management and Source Control<br />

method is to create an authoritative source database; a database you would treat like a<br />

production system, where you maintain what your source data should look like. You can<br />

add effective dates, expiration dates, and flags to determine if a piece of data is ready for<br />

a production rollout. A basic lookup table, consisting of an ID/Value pair, would look<br />

something like the one in Listing 3-3.<br />

CREATE TABLE dbo.IvLookup<br />

(<br />

ID INT NOT NULL IDENTITY(1,1) ,<br />

IvValue NVARCHAR(50) NOT NULL ,<br />

EffDate DATETIME NOT NULL ,<br />

ExpDate DATETIME NULL ,<br />

ProductionReady BIT NOT NULL ,<br />

IsDeleted BIT NOT NULL ,<br />

AppLabel NVARCHAR(30) NOT NULL ,<br />

PRIMARY KEY CLUSTERED ( ID )<br />

);<br />

Listing 3-3: A lookup table in the authoritative source database.<br />

The data stored in a table following this approach allows for a number of control points<br />

to help dictate which data is ready for use in various environments. The ID and IVvalue<br />

columns for the lookup information are the easiest to describe. These would be artificial<br />

keys and associated values that provide the lookup information. The effective and<br />

expiration dates, EffDate and ExpDate, can be used to return only data that is active<br />

within a given time period. The bit fields ProductionRead and IsDeleted can be<br />

used to mark a value as being either ready for release to production, or logically deleted.<br />

Logical deletion is the best way to maintain data integrity and yet remove lookup values<br />

from active lists within the application. By labeling the software version that last updated<br />

the value, AppLabel, the data can be associated with a particular rollout, especially when<br />

the deployments are incremental, meaning that we are only deploying changes rather<br />

than performing a complete redeployment of a database.<br />

89

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!