Presentation is loading. Please wait.

Presentation is loading. Please wait.

2 DAT320 Testing and Refactoring Your Database with Visual Studio Team Edition for Database Professionals.

Similar presentations


Presentation on theme: "2 DAT320 Testing and Refactoring Your Database with Visual Studio Team Edition for Database Professionals."— Presentation transcript:

1

2 2 DAT320 Testing and Refactoring Your Database with Visual Studio Team Edition for Database Professionals

3 3

4 4 DAT320 Testing and Refactoring Your Database with Visual Studio Team Edition for Database Professionals (Part 2) Sachin Rekhi Program Manager Microsoft Corporation Gert E.R. Drapers Architect/Development Manager Microsoft Corporation

5 5 Agenda The Database Development Life Cycle The Database Developer Story Data Generation Database Unit Testing Schema Refactoring The Power of Integration Summary

6 6 Other Sessions Introducing Visual Studio Team Edition for Database Professionals DEV217 - 6/13/2006 10:15AM - 11:30AM, room: 104 ABC Managing and Deploying your SQL Server Schemas with Visual Studio Team Edition for Database Professionals DAT312 - 6/13/2006 1:00PM - 2:15PM, room: 156 ABC Testing & Refactoring your Database with Visual Studio Team Edition for Database Professionals DAT320 - 6/14/2006 8:30AM - 9:45AM, room: 160 ABC Under the Hood of Visual Studio Team Edition for Database Professionals DAT433 - 6/15/2006 1:00PM - 2:15PM, room: 160 ABC

7 7 Product Overview Database Project System Schema and Script Versioning (SCC Integration) Schema Build & Deploy Schema Compare Data Compare Database Unit Testing (Test) Data Generator Schema Refactoring T-SQL Editor with Query Execution Work Item and Process Integration with TFS

8 8 Project Model The center of gravity The database project represents the “truth” with regards to schema versioning Optionally database project can be placed under source control.SQL script files is the canonical format used Changes are tracked at the “object level” For example indexes, constraints, triggers are tracked independent of the base table definition, in order have the highest granularity of change tracking

9 9 Database Development Life Cycle The cycle of life for database developers DatabaseProject (*) Not implemented in the current CTP Import database schema Reverse engineer existing.SQL script files (*) Create New Project SQLScript DatabaseProjectTemplate SQL Server Database

10 10 Database Development Life Cycle The cycle of life for database developers DatabaseProject Edit Compare Test Build Data Generation Deploy Refactor Compare

11 11 Database Development Life Cycle The cycle of life for database developers DatabaseProject (*) Not implemented in the current CTP Import database schema Reverse engineer existing.SQL script files (*) Create New Project SQLScript DatabaseProjectTemplate SQL Server Database Deploy SQL Script SQL Server Database Build project Deploy project

12 12 Continuing the Journey… In part 1 we established: A Database Project representing our schema Placed it under version control Create a sandbox environment using Build & Deploy Verified if the sandbox matches the project and the original database, using Schema Compare Now we are ready to start making changes! First we are going to create test data Which will be used by the test bed we are creating So we can validate our changes made using Schema Refactoring

13 13 Data Generation Design Time Setting up Data Generation implies defining: Which generator to use Which distribution to attach to the generator Changing setting on the generator & distribution The numbers of rows to generate Optionally defining the rowcount ratios between tables By default: Each column is bound to the generator matching the column data type FK columns are mapped to the Foreign Key generator Uniqueness is inferred from PK, UC constraints and indexes Using the Uniform distribution when not unique

14 14 Data Generation Design Time Value generators Simple generators for each data type Strings: ASCII and Unicode ((var)char, n(var)char, (n)text) Numbers: tinyint, smallint, int, bigint, real, float, decimal, numeric, money Binary ((var)binary, image) Date and Time UniqueIdentifier (GUID) Bit Complex generators Foreign Key, Regular Expression, Data Bound Distributions Uniform, Normal, Inverse Normal, Exponential, Inverse Exponential Can import column distributions from production database (*) (*) Not implemented in the current CTP

15 15 Data Generation Distributions @ Work

16 16 Data Generation Design Time Understand domain constraints Check constraints (min/max) Table cardinality Enforce table ratios Column value distribution

17 17 Data Generation Executing a Data Generation Definition Validation of Security requirements Fails when security requirements are not met! Target schema against DGEN definitions Fails the generation when bindings do not match! Optionally purge tables Required to guarantee repeatable data generation Spin up parallel streams of INSERT statements Based on relation ships between tables Number of connections used is currently gated by the schema relationships. Configurable Error Thresholds

18 18 Data Generation Customization & Extensibility Customization of value generation RegEx Generator Data Bound Generator Extensibility Custom Generator Custom Distribution Discussed in detail in: Under the Hood of Visual Studio Team Edition for Database Professionals DAT433 - 6/15/2006 1:00PM - 2:15PM, room: 160 ABC

19 19 Sachin Rekhi Program Manager Visual Studio Team System Data Generation

20 20 Database Unit Testing Design Time Automatically generate unit tests stubs for: Stored Procedures, Functions (*), Triggers (*) Test Validation (assertions) T-SQL (server based) Assertions RAISERROR command Client Side Assertions None Empty ResultSet Row Count Execution Time, … Pre & Post Test Scripts (*) Not implemented in the current CTP

21 21 Database Unit Testing Test Execution Automatic Deployment Integration Automatically deploy database project prior to running tests (*) Data Generation Integration Automatically generate data based on generation plan prior to running tests Execution & Validation connections Validation connection can be higher privileged account (*) Not implemented in the current CTP

22 22 Database Unit Testing Customization & Extensibility Database Unit Test designer generates C# or VB.NET code Can customize generated code for: Custom test validation logic Parameterized test support Managing transactions Additional test setup and teardown of tests Discussed in detail in: Under the Hood of Visual Studio Team Edition for Database Professionals DAT433 - 6/15/2006 1:00PM - 2:15PM, room: 160 ABC

23 23 Sachin Rekhi Program Manager Visual Studio Team System Database Unit Testing

24 24 Database Schema Refactoring What is refactoring? “A database refactoring is a small change to your database schema which improves its design without changing its semantics.” Agile Database Development, Scott Ambler For example: Rename a Schema Object Name for consistency, understandability, maintainability… Objective: Rename ALL schema object references; direct and indirect inside all: Tables, views, stored procedures, user defined functions, …

25 25 Database Schema Refactoring Rename Refactoring… Rename any SQL 2000 & SQL 2005 schema object Updates all references in… Schema Objects Data Generation Plans Scripts Database Unit Tests Preview changes prior to commit Global undo to reverse all changes

26 26 Database Schema Refactoring Refactoring Safety Net Unit Testing Develop a battery of tests to run after a refactoring to ensure database still functions as expected Version Control Store all previous versions so you can always go back to a prior baseline in source control Schema Compare Analyze the exact differences between the project and live database to understand the impact of the update

27 27 Sachin Rekhi Program Manager Visual Studio Team System Schema Refactoring

28 28 Integrating In To The Cycle of Life DatabaseProject Edit Compare Test Build Data Generation Deploy Refactor Compare

29 29 Sachin Rekhi Program Manager Visual Studio Team System End-to-End Database Development

30 30 Summary Handle Schema Change Management and Deployment Mitigate the Risks Involved with making and deploying changes Integrate the Database Professional in to the Development Life Cycle

31 31 Resources Break-out Sessions Under the Hood of Visual Studio Team Edition for Database Professionals DAT433 - 6/15/2006 1:00PM - 2:15PM, room: 160 ABC Hands on Labs DEV008 Take a Tour of Visual Studio 2005 Team System for Database Professionals Chalk Talks Visual Studio Team Edition for Database Professionals: Overview DEV TLC Theatre 6/15/2006 9:45AM-11:00AM

32 32 Resources… CTP 3 Download Site http://download.microsoft.com/download/1/a/3/1a32ea84-11a3- 4adf-953e-7a65b9831f5a/VSDATAD1.img http://download.microsoft.com/download/1/a/3/1a32ea84-11a3- 4adf-953e-7a65b9831f5a/VSDATAD1.img Team Website http://msdn.microsoft.com/vstudio/teamsystem/products/dbpro/de fault.aspx http://msdn.microsoft.com/vstudio/teamsystem/products/dbpro/de fault.aspx Product Forum http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=7 25&SiteID=1 http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=7 25&SiteID=1 PowerToys and Samples http://gotdotnet.com/Workspaces/Workspace.aspx?id=378460fd- 1254-427b-aa7d-e777a826a564 http://gotdotnet.com/Workspaces/Workspace.aspx?id=378460fd- 1254-427b-aa7d-e777a826a564Blogs http://blogs.msdn.com/gertd

33 33 Fill out a session evaluation on CommNet for a chance to Win an XBOX 360!

34 © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Download ppt "2 DAT320 Testing and Refactoring Your Database with Visual Studio Team Edition for Database Professionals."

Similar presentations


Ads by Google