Presentation is loading. Please wait.

Presentation is loading. Please wait.

Team Edition for Database Professionals

Similar presentations


Presentation on theme: "Team Edition for Database Professionals"— Presentation transcript:

1 Team Edition for Database Professionals
Maor David Senior Consultant (MCAD) SRL Software Solutions Ltd.

2 Agenda Acquaintance What is Visual Studio Team System?
Module 1: Getting started with VSTS for DB Professionals Module 2:Creating & Updating Version Controlled Database schemas Module 3: Editing database scripts and objects with the T-SQL Editor Module 4: Generating data with data generators Module 5: Comparing databases Module 6: Verifying databases with Unit Tests Module 7: Refactoring databases Q&A

3 Acquaintance Student background Full Name Company Function in company
Experience with Visual Studio Team System Experience with SQL Server 2000/2005 Reasons for coming here today Expectations from the course

4 What is Visual Studio Team System?

5 VS Team System 9/21/2018 4:58 AM 5 Architect Tester Developer
Project Manager Tester Designer Developer VS Team System Expand to development team Business results from IT Team productivity and collaboration Integrated quality 5 © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

6 9/21/2018 4:58 AM 6 CIO PMO Architect Tester Developer Project Manager
Business Analyst PMO Operations CIO Application Support Architect Project Manager Tester Designer Developer 6 © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

7 Team Edition for Database Professionals
Business Analyst PMO Operations CIO Application Support Architect Project Manager Tester Designer Developer Team Edition for Database Professionals Expand to database teams Manage Database Change Extend Team productivity and collaboration Integrated quality DB Pro 7 © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

8 Module 1: Getting started with VSTS for DB Professionals

9

10 What is “VSTS for DB Professionals”?
We’ll refer to it as TSDB or “Data Dude” The latest addition to “Team System” Integrates the Database development life cycle into “Team System” enterprise development infrastructure.

11 “Why did we built it…?” Managing Database Change is hard…
changes to the schema throughout the development process and after deployment Managing Database State is hard… What’s the state for the Dev, Test, or Prod environments It’s hard to track changes to the database Managing Database Testing is hard… It’s hard to consistently establish the state of the database I can’t use my live production data Disconnect between development and database teams Developers may make poor database design decisions Needs to be more integrated

12 Product Overview (1) Database Project System
9/21/2018 4:58 AM Product Overview (1) Database Project System Schema and Script Versioning SCC Integration T-SQL Editor with Query Execution Database Schema Management Build & Deploy Schema Compare Data Compare © 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.

13 Product Overview (2) Database Unit Testing (Test) Data Generator
9/21/2018 4:58 AM Product Overview (2) Database Unit Testing (Test) Data Generator Stored Procedure Unit Testing Schema Refactoring Version 1: Change names, only Future versions: indexes, constraints, relations Team Foundation Server Integration Work Item Tracking Process Integration © 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.

14 Database development lifecycle
The database development lifecycle contains the following phases: Establish the project environment Perform isolated, iterative development Build the project Deploy from the project environment

15 Database Development Life Cycle
9/21/2018 4:58 AM Database Development Life Cycle Edit Refactor Compare Database Project Deploy Build Data Generation Test Compare © 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.

16 Establish the Project Environment
The DBA starts by creating a database project and importing the database schema from the production database. The DBA then can create a data generation plan to create test data for the isolated development environments. Finally, the DBA checks the database project into version control, which makes it available to the team.

17 Perform Isolated, Iterative Development
Each database professional synchronizes their development environment to version control. They can check out files as they are changed and develop and test those changes in isolation. Changes made to their copy of the database project are deployed only to their isolated development environment. After a team member generates realistic test data and runs unit tests against a private copy of the database, the team member checks the changes into version control. Other team members obtain tested changes from version control.

18 Generate Daily Builds of the Project
The daily build is generated by synchronizing to the most recent tested version of the database project in the version control system. That build can be deployed to a test database where unit tests are run against generated test data.

19 Deployment from the Project Environment
When it is time to deploy a version of the database to production, the DBA synchronizes to a label from the version control system. The DBA retrieves matching files for the database project, related scripts, and tests. Next, the DBA builds the deployment script, makes manual modifications as needed, and does a test deployment to the staging server. The DBA iterates this process until the script is ready to be deployed to the production server. If the DBA made changes to the schema or to the pre-deployment or post-deployment scripts, those changes will be checked back in to version control.

20 Conceptual Overview Production Database
TechReady4 Conceptual Overview Production Database Management Studio Tuning Monitoring Difficult to Manage Change to the schema Production Database is one version of the truth for Data and Schema DBA doesn’t have access to changes until he/she has deploy or reject choice Changes often made to production database and not rolled back into test Schema Schema Changes “One Version of the Truth” for Data and Schema © 2007 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

21 Conceptual Overview Production Database Management Studio Schema
TechReady4 Conceptual Overview Production Database Management Studio Schema Change now managed in VSTS and TFS Production Database is now “One version of the truth” only for Data DBA doesn’t have access to changes until he/she has deploy or reject choice “One Version of the truth for Schema” is Under Source Control Tuning Monitoring “One Version of the Truth” for Data Changes can be rolled out in a scheduled, managed way Scripts allow administrators to mange change updates “One Version of the Truth” for Schema Offline Under Source Control Schema Schema Changes © 2007 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

22 Build & Deploy SQL Server Database Deploy SQL Script Database Project
Import database schema Build project Database Project Template Database Project Create New Project Deploy project SQL Server Database SQL Script Reverse engineer existing .SQL script files

23 Building Using MSBuild
9/21/2018 4:58 AM Building Using MSBuild Build – New database script msbuild NorthwindOnline.dbproj /t:build msbuild NorthwindOnline.dbproj /t:build /p:Configuration="New Deployment" Build – Update for defined target server msbuild NorthwindOnline.dbproj /t:build /p:Configuration="Update Deployment" /p:TargetConnectionString="Data Source=(local)\sql80;Integrated Security=True;Pooling=False;" /p:TargetDatabase="NorthwindOnlineTestRun" © 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.

24 Deploying Using MSBuild
9/21/2018 4:58 AM Deploying Using MSBuild Deploy – New database msbuild NorthwindOnline.dbproj /t:deploy /p:Configuration="New Deployment" Deploy – Update Database msbuild NorthwindOnline.dbproj /t:deploy /p:Configuration="Update Deployment" /p:TargetConnectionString="Data Source=(local)\sql80;Integrated Security=True;Pooling=False;" © 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.

25 Misc. Actions Using MSBuild
9/21/2018 4:58 AM Misc. Actions Using MSBuild All (Build + Deploy) msbuild NorthwindOnline.dbproj /t:all Clean msbuild NorthwindOnline.dbproj /t:clean msbuild NorthwindOnline.dbproj /t:clean /p:Configuration="New Deployment" msbuild NorthwindOnline.dbproj /t:clean /p:Configuration="Update Deployment" © 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.

26 MSBuild Task: SqlBuild/SqlDeploy
9/21/2018 4:58 AM MSBuild Task: SqlBuild/SqlDeploy BuildType { "New Deployment" | "Update Deployment“ } TargetConnectionString TargetDatabase Build options: DefaultCollation {"True" | "False“} EnableFullTextIndexing {"True" | "False“} ScriptCreateDBStatement {"True" | "False“} GenerateDropsIfNotInProject {"True" | "False“} SourceDatabase {"True" | "False“} Set options: ARITHABORT {"True" | "False“} NUMERIC_ROUNDABORT {"True" | "False“} ANSI_NULLS {"True" | "False“} CONCAT_NULL_YIELDS_NULL {"True" | "False“} ANSI_PADDING {"True" | "False“} ANSI_WARNINGS {"True" | "False“} QUOTED_IDENTIFIER {"True" | "False“} © 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.

27 Provisioning Multiple Servers
How can I deploy to multiple targets? The Database Project only understand a single target server/database at the time You can use the MSBuild tasks to provision multiple servers Using command line or tool that calls the MSBuild infrastructure Pseudo code for each server+database combination in list { SqlBuildTask SqlDeployTask }

28 Key Points to Note DB PRO project is the master version
Each DB object is represented by a separate script (i.e. ‘.sql’ file) DB Pro Project not connected to DB ! Script files Managed through TFS Source Control Versioning, branching & CheckIn/CheckOut TFS & MSBuild is an option for deployment

29 Module 2: Creating & Updating Version Controlled Database schemas

30 The Project Model 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

31 Database Projects Defined
“Schema” projects SQL Server 2000 SQL Server 2005 “Script Only” projects Different types to support different syntax/language options A project is simply a series of files collected together into a single logical collection

32 Off-line Development Production Database Test Database
Create table AUCTION ( id int not null, title varchar(25) not null, startDate DateTime not null, length in not null) Test Database

33 Off-line Development Import database schema to populate project from existing database Changes to schema traditionally have immediate affect With off-line project nothing changes until you deploy the change

34 Database Development Life Cycle
SQL Server Database Import database schema Database Project Template Database Project Create New Project SQL Script Reverse engineer existing .SQL script files (*)

35 File Naming & Extension Scheme
Everything is a .SQL file Associated with the T-SQL editor Using a two part naming scheme to identify types This is not required, but helps identification of types By default the file name encodes the object name Not required Filename do not have to match the containing type name Required since SQL Server namespace restrictions do not match the file system naming restrictions

36 Directory Structure SQL 2000 Project
Data Generation Plans Schema Objects Functions Stored Procedures Tables Views Security Roles Users Application Roles Database Roles Storage File Groups Full Text Catalogs Types User-defined Data Types Scripts Post-Deployment Pre-Deployment

37 Directory Structure SQL 2005 Project
9/21/2018 4:58 AM Directory Structure SQL 2005 Project Data Generation Plans Schema Objects Aggregates Assemblies Database Triggers Functions Security Asymmetric Keys Certificates Endpoints Roles Application Roles Database Roles Schemas Symmetric Keys Users Service Broker Contracts Event Notifications Message Types Queues Remote Service Binding Routes Services Schema Objects… Storage File Groups Full Text Catalogs Partition Functions Partition Schemes Stored Procedures Synonyms Tables Types User-defined Data Types User-defined Types (CLR) XML Schema Collections Views Scripts Post-Deployment Pre-Deployment © 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.

38 Lab Creating & Updating Version Controlled Database schemas

39 Module 3: Editing database scripts and objects with the T-SQL Editor

40 Transact-SQL Editor features
All common features for Visual Studio editors, which include find and replace, bookmarks, block indent and un-indent, integration with the Visual Studio Error List window, and block commenting and un-commenting. Support for shortcut keys compatible with other editors and SQL Server Management Studio. Validation of SQL syntax without executing the script or query.

41 Transact-SQL Editor features Cont.
Ability to edit while disconnected. Multiple sets of query results, displayed either as a grid, as text, or saved to a file on disk. Ability to execute multiple queries in one editor instance, with multiple result sets generated. The queries are executed sequentially. Support for SQLCMD

42 Lab Create and Execute a Simple Transact-SQL Script

43 Module 4: Generating data with data generators

44 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 (*) Generators Simple: UnicodeString Image SmallInt DatabaseGuid AsciiString VarBinary TinyInt DatabaseFloat DatabaseDateTime BigInt Money Int DatabaseDecimal DatabaseReal Bit Complex: DataBoundGenerator RegexString ForeignKey Distributions: Uniform Normal NormalInverse Exponential ExponentialInverse

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

46 Generation Data - Distributions @ Work
9/21/2018 4:58 AM Generation Data - Work © 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.

47 Data Generation - Execution
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 relationships between tables Number of connections used is currently gated by the schema relationships. Configurable Error Thresholds

48 Data Generation - Customizing
Customization of value generation RegEx Generator (*) Data Bound Generator (*) Extensibility Custom Generator Custom Distribution

49 Lab Data Generation

50 Module 5: Comparing databases

51 Schema Compare What is Schema Compare? Allows quick comparisons of:
project -> database database -> database GUI interface and/or SQL scripts to compare diffs Full SQL Server 2000 and SQL Server 2005 support Object level script differences between databases

52 Schema Compare Options for restricting/changing script
Restrict which object types are compared Compare while ignoring schema, filegroups, etc. Enables comparison of test to production Turn off dependency checking Generate backwards compatible scripts i.e. script a 2005 database with a 2000 script Compare security settings Users, roles, and permissions

53 Data Compare Connects to 2 databases and compares all data.
Tables and Views Differences can be: Different rows Identical rows Only in source Only in target Can update target immediately from GUI or export to script Can customize updates for specific tables Can customize updates for specific rows

54 Lab Comparing databases

55 Module 6: Verifying databases with Unit Tests

56 A Rollback Means a LONG Night
Unit Testing helps ensure that changes do not break existing code Unit test designer is SQL focused Work in the language of your choice: TSQL, VB, C# Builds on existing Team Test Unit Test functionality

57 What We Can Test Stored Procedures Functions Triggers Arbitrary SQL
Automatically deploy changes to test system and generate data Deterministic data generation ensures stable test state Can test with your application tier because of common framework

58 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 Non Empty Result Set Row Count Execution Time, … Pre & Post Test Scripts

59 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

60 Database Unit Testing Customization
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

61 Lab Verifying databases with Unit Tests

62 Module 7: Refactoring Databases

63 What is re factoring? “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, …

64 Refactoring Bring power of refactoring to SQL Cascading Change
Update all dependent objects in database project Schema objects, Data generation, Unit Tests, SQL Scripts Preview all changes Make an atomic change Global Undo Rename Meet corporate standards Better express semantic intent – clarity

65 Database Schema 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

66 Database Schema Refactoring
Unit Testing Run after a re factoring 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

67 Lab Refactoring Databases

68 Points to take home ! Managed, project oriented evolution of database schema – no more rollbacks Application and database schema can now be managed together Work in “isolation”, deploying only when changes verified Leverage VSTS work item tracking and process guidance Thank You! Blog :

69 Public CTP of VS DB Pro SR1 available
3+4 part name resolution through a new feature called "database references" File groups and files are now part of the project settings and can be fully parameterize then to fit your deployment needs (this replaces the need for the storage deployment script) SQLCMD variable support; this is enable through a new project property page for creating and editing variables that you can then use inside your scripts. Variables are stored inside the project file and can be mapped to MSBuild properties.

70 Q & A?

71 Useful links Blogs SRLTeam http://blogs.microsoft.co.il/blogs/srlteam
Gert Mairéad Cameron Team System For DB Pro Home White Papers What Microsoft Visual Studio 2005 Team Edition for Database Professionals Can Do for You A Security Overview of Microsoft Visual Studio 2005 Team Edition for Database Professionals Samples Forum


Download ppt "Team Edition for Database Professionals"

Similar presentations


Ads by Google