SlideShare a Scribd company logo
1 of 25
Treating Databases as First-
Class Citizens in Development
  Rob Bagby
  Developer Evangelist
  Microsoft Corporation
  www.RobBagby.com
  Rob.Bagby@Microsoft.com
Agenda
Overview
The Database Project
(Test) Data Generation
Unit Tests
Managing Change
Q&A
Some Important Questions
ā€¢ Where is the ā€œtruthā€ for my schema?
    ā€“ Production?
    ā€“ What about bug fixes?
    ā€“ What about version next?
    How do I version my databases?
ā€¢
    What do I do for test data?
ā€¢
    How do I test my database logic?
ā€¢
    What tools do I use to differentiate
ā€¢
    schemas, data?
Challenge                   Solution
                            ā€¢ Multiple Truths, stored
ā€¢ Whereā€™s the truth?
                              offline
                            ā€¢ The same way I version
ā€¢ How do I version?
                              source code
ā€¢ Where do I get test data? ā€¢ Test Data Generator

ā€¢ How do I unit test?       ā€¢ The same way I test
                              source code (with a little
                              SQL love thrown in)
ā€¢ What tools do I have to   ā€¢ Schema Compare, Data
  manage change?              Compare, Refactoring
The ā€œTruthā€ of my schema
ā€¢ The production DB is only 1 version of the
  truth of your schema
ā€¢ There may be bug fixes in Q/A right
  now, waiting deployment
ā€¢ There may be development going on right
  now by multiple developers / teams
Project Model
ā€¢ The database project represents the
  ā€œtruthā€ of your schema
ā€¢ The project contains the schema (*.sql
  files)
ā€¢ Use version control to manage different
  versions
Database Development Lifecycle

     SQL
    Server
   Database
                  Database
                   Project
    Database
     Project
    Template



      SQL
     Script
Database Development Lifecycle
              Edit

            Refactor
            Compare



   Deploy              Build
            Database
             Project




            Data Gen

               Test
            Compare
Version Control Challenge
     class class class AuctionApplication
            AuctionApplication
                  AuctionApplication
                                                          App
     (     (     (
      int id; id;
            int int      id;
      void MethodA();
            void MethodA();
                  string cacheTitle;
            void MethodB();
                  void MethodA();
     )
           )      void MethodB();
                 )



           V3                               Revision History
     V2
V1

     CREATE TABLE dbo.Auction
          ALTER ALTER TABLE dbo.Auction
                 TABLE dbo.Auction                      Database
     (     WITH CHECK CHECK ADD CONSTRAINT
                 WITH ADD CONSTRAINT
      id    INT NOT NULL, KEY (id)
            Au_PK Au_SK UNIQUE (name)
                   PRIMARY
      name VARCHAR(25) NOT NULL,
      start DATETIME NULL,
      len   INT NULL
     )
Manual Versioning
-- version 1 Add table dbo.Auction
IF OBJECT_ID (N'dbo.Auction', N'U') IS NULL
BEGIN
CREATE TABLE dbo.Auction
(
    id    INT NOT NULL,
    name VARCHAR(25) NOT NULL,
    start DATETIME NULL,
    len   INT NULL
)
END
-- version 2 Add PK Au_PK
IF NOT EXISTS (SELECT * FROM sys.key_constraints WHERE name = 'Au_PK' AND type = 'PK')
BEGIN
    ALTER TABLE Auction
    WITH CHECK ADD CONSTRAINT Au_PK PRIMARY KEY (id)
END
-- version 3 Add UC Au_SK
IF NOT EXISTS (SELECT * FROM sys.key_constraints WHERE name = 'Au_SK' AND type = ā€˜UQ')
BEGIN
    ALTER TABLE Auction
    WITH CHECK ADD CONSTRAINT Au_SK UNIQUE (name)
END
Version Control
                     The ā€œData dudeā€ approach
     class class class AuctionApplication
            AuctionApplication
                  AuctionApplication
                                                          App
     (     (     (
      int id; id;
            int int      id;
      void MethodA();
            void MethodA();
                  string cacheTitle;
     )      void MethodB();
                  void MethodA();
           )      void MethodB();
                 )



     V2 V3                                  Revision History
V1
     CREATE TABLE TABLE TABLE dbo.Auction
          CREATE dbo.Auction
                 CREATE dbo.Auction                      Logical
     (    (      (
                                                        Database
      id    id
             INT NOT NULL, NULL PRIMARY KEY, KEY,
                  id
                   INT NOT NOT NULL PRIMARY
                        INT
      name name name VARCHAR(25) NOT NULL UNIQUE,
             VARCHAR(25) NOT NULL, NULL,
                   VARCHAR(25) NOT
      start start start DATETIME NULL,
             DATETIME NULL, NULL,
                   DATETIME
      len len NULL NULL NULL
             INT len
                   INT INT
     )    )      )
Deployment
                    The ā€œData dudeā€ approach
     CREATE TABLE TABLE TABLE dbo.Auction
          CREATE dbo.Auction
                 CREATE dbo.Auction                    Logical
          (      (
     (
                                                      Database
      id    id
             INT NOT NULL, NULL PRIMARY KEY, KEY,
                  id
                   INT NOT NOT NULL PRIMARY
                        INT
      name name name VARCHAR(25) NOT NULL UNIQUE,
             VARCHAR(25) NOT NULL, NULL,
                   VARCHAR(25) NOT
      start start start DATETIME NULL,
             DATETIME NULL, NULL,
                   DATETIME
      len len NULL NULL NULL
             INT len
                   INT INT
     )    )      )



     V2 V3                                Revision History
V1


   New                                               Incremental
                CREATE TABLE dbo.Auction
                    ALTER TABLE dbo.Auction
Deployment                                           Deployment
                (
                     WITH CHECK ADD CONSTRAINT
                 id     INT NOT NULL PRIMARY KEY,
                      Au_SK UNIQUE (name)
                 name VARCHAR(25) NOT NULL UNIQUE,
                 start DATETIME NULL,
                 len    INT NULL
                )
demo
 The Project Model
Agenda
Overview
The Database Project
(Test) Data Generation
Unit Tests
Managing Change
Q&A
Test Data Q & A
ā€¢ Why not production data?
  ā€“ Ahhh, it may be illegal
  ā€“ Doesnā€™t test edge cases
  ā€“ Doesnā€™t address schema changes
ā€¢ What are our test data requirements?
  ā€“ ā€œRandomā€
  ā€“ Deterministic
  ā€“ Appropriately distributed
  ā€“ā€¦
Test Data Q & A (continued)
ā€¢ What are the differing needs for test data?
  ā€“ Functional Test
  ā€“ Load Test
ā€¢ What are the versioning implications
  ā€“ We need differing plan(s) for differing
    schemas
  ā€“ We need to version plans along side schemas
(Test) Data Generation in VSTS
Choose the following
ā€¢ The Tables
ā€¢ Number of rows (RowCount ratios help)
ā€¢ The generator for each column
      Out of the box: string, RegEx, data bound, etc.
  ā€“
      Write your own
  ā€“
      Set generator-specific settings
  ā€“
      Set the seed ā€“ provides determinism
  ā€“
ā€¢ The distribution
demo
 (Test) Data Generation
Agenda
Overview
The Database Project
(Test) Data Generation
Unit Tests
Managing Change
Q&A
Database Unit Testing
ā€¢ Automatically generate unit test 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 and Post Test Scripts
Database Unit Testing
ā€¢ 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
demo
 Database Unit Tests
Agenda
Overview
The Database Project
(Test) Data Generation
Unit Tests
Managing Change
Q&A
What kind of change can we
            manage?
ā€¢ Refactoring
ā€¢ Compare schemas
ā€¢ Compare data
demo
 Managing Change

More Related Content

What's hot

Avoiding cursors with sql server 2005 tech republic
Avoiding cursors with sql server 2005   tech republicAvoiding cursors with sql server 2005   tech republic
Avoiding cursors with sql server 2005 tech republicKaing Menglieng
Ā 
qooxdoo Form Management
qooxdoo Form Managementqooxdoo Form Management
qooxdoo Form ManagementMartin Wittemann
Ā 
C# Starter L02-Classes and Objects
C# Starter L02-Classes and ObjectsC# Starter L02-Classes and Objects
C# Starter L02-Classes and ObjectsMohammad Shaker
Ā 
CREATE INDEX ā€¦ USING VODKA. VODKA CONNECTING INDEXES, ŠžŠ»ŠµŠ³ Š‘Š°Ń€Ń‚ŃƒŠ½Š¾Š², ŠŠ»ŠµŠŗсŠ°Š½Š“...
CREATE INDEX ā€¦ USING VODKA. VODKA CONNECTING INDEXES, ŠžŠ»ŠµŠ³ Š‘Š°Ń€Ń‚ŃƒŠ½Š¾Š², ŠŠ»ŠµŠŗсŠ°Š½Š“...CREATE INDEX ā€¦ USING VODKA. VODKA CONNECTING INDEXES, ŠžŠ»ŠµŠ³ Š‘Š°Ń€Ń‚ŃƒŠ½Š¾Š², ŠŠ»ŠµŠŗсŠ°Š½Š“...
CREATE INDEX ā€¦ USING VODKA. VODKA CONNECTING INDEXES, ŠžŠ»ŠµŠ³ Š‘Š°Ń€Ń‚ŃƒŠ½Š¾Š², ŠŠ»ŠµŠŗсŠ°Š½Š“...Ontico
Ā 
R Programming: Comparing Objects In R
R Programming: Comparing Objects In RR Programming: Comparing Objects In R
R Programming: Comparing Objects In RRsquared Academy
Ā 
Diving into MySQL 5.7: advanced features
Diving into MySQL 5.7: advanced featuresDiving into MySQL 5.7: advanced features
Diving into MySQL 5.7: advanced featuresGabriela Ferrara
Ā 
Uma Abordagem Orientada a Modelos para Modelagem Conceitual de Banco de Dados
Uma Abordagem Orientada a Modelos para Modelagem Conceitual de Banco de DadosUma Abordagem Orientada a Modelos para Modelagem Conceitual de Banco de Dados
Uma Abordagem Orientada a Modelos para Modelagem Conceitual de Banco de DadosCarlos Eduardo Pantoja
Ā 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javacAnna Brzezińska
Ā 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursorsinfo_zybotech
Ā 
dbms lab manual
dbms lab manualdbms lab manual
dbms lab manualstalinjothi
Ā 
Ā«Objective-C Runtime Š² ŠæрŠøŠ¼ŠµŃ€Š°Ń…Ā» ā€” ŠŠ»ŠµŠŗсŠµŠ¹ Š”тŠ¾Ń€Š¾Š¶ŠµŠ², e-Legion
Ā«Objective-C Runtime Š² ŠæрŠøŠ¼ŠµŃ€Š°Ń…Ā» ā€” ŠŠ»ŠµŠŗсŠµŠ¹ Š”тŠ¾Ń€Š¾Š¶ŠµŠ², e-LegionĀ«Objective-C Runtime Š² ŠæрŠøŠ¼ŠµŃ€Š°Ń…Ā» ā€” ŠŠ»ŠµŠŗсŠµŠ¹ Š”тŠ¾Ń€Š¾Š¶ŠµŠ², e-Legion
Ā«Objective-C Runtime Š² ŠæрŠøŠ¼ŠµŃ€Š°Ń…Ā» ā€” ŠŠ»ŠµŠŗсŠµŠ¹ Š”тŠ¾Ń€Š¾Š¶ŠµŠ², e-Legione-Legion
Ā 

What's hot (13)

Avoiding cursors with sql server 2005 tech republic
Avoiding cursors with sql server 2005   tech republicAvoiding cursors with sql server 2005   tech republic
Avoiding cursors with sql server 2005 tech republic
Ā 
Green dao
Green daoGreen dao
Green dao
Ā 
Green dao
Green daoGreen dao
Green dao
Ā 
qooxdoo Form Management
qooxdoo Form Managementqooxdoo Form Management
qooxdoo Form Management
Ā 
C# Starter L02-Classes and Objects
C# Starter L02-Classes and ObjectsC# Starter L02-Classes and Objects
C# Starter L02-Classes and Objects
Ā 
CREATE INDEX ā€¦ USING VODKA. VODKA CONNECTING INDEXES, ŠžŠ»ŠµŠ³ Š‘Š°Ń€Ń‚ŃƒŠ½Š¾Š², ŠŠ»ŠµŠŗсŠ°Š½Š“...
CREATE INDEX ā€¦ USING VODKA. VODKA CONNECTING INDEXES, ŠžŠ»ŠµŠ³ Š‘Š°Ń€Ń‚ŃƒŠ½Š¾Š², ŠŠ»ŠµŠŗсŠ°Š½Š“...CREATE INDEX ā€¦ USING VODKA. VODKA CONNECTING INDEXES, ŠžŠ»ŠµŠ³ Š‘Š°Ń€Ń‚ŃƒŠ½Š¾Š², ŠŠ»ŠµŠŗсŠ°Š½Š“...
CREATE INDEX ā€¦ USING VODKA. VODKA CONNECTING INDEXES, ŠžŠ»ŠµŠ³ Š‘Š°Ń€Ń‚ŃƒŠ½Š¾Š², ŠŠ»ŠµŠŗсŠ°Š½Š“...
Ā 
R Programming: Comparing Objects In R
R Programming: Comparing Objects In RR Programming: Comparing Objects In R
R Programming: Comparing Objects In R
Ā 
Diving into MySQL 5.7: advanced features
Diving into MySQL 5.7: advanced featuresDiving into MySQL 5.7: advanced features
Diving into MySQL 5.7: advanced features
Ā 
Uma Abordagem Orientada a Modelos para Modelagem Conceitual de Banco de Dados
Uma Abordagem Orientada a Modelos para Modelagem Conceitual de Banco de DadosUma Abordagem Orientada a Modelos para Modelagem Conceitual de Banco de Dados
Uma Abordagem Orientada a Modelos para Modelagem Conceitual de Banco de Dados
Ā 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Ā 
Accessing data with android cursors
Accessing data with android cursorsAccessing data with android cursors
Accessing data with android cursors
Ā 
dbms lab manual
dbms lab manualdbms lab manual
dbms lab manual
Ā 
Ā«Objective-C Runtime Š² ŠæрŠøŠ¼ŠµŃ€Š°Ń…Ā» ā€” ŠŠ»ŠµŠŗсŠµŠ¹ Š”тŠ¾Ń€Š¾Š¶ŠµŠ², e-Legion
Ā«Objective-C Runtime Š² ŠæрŠøŠ¼ŠµŃ€Š°Ń…Ā» ā€” ŠŠ»ŠµŠŗсŠµŠ¹ Š”тŠ¾Ń€Š¾Š¶ŠµŠ², e-LegionĀ«Objective-C Runtime Š² ŠæрŠøŠ¼ŠµŃ€Š°Ń…Ā» ā€” ŠŠ»ŠµŠŗсŠµŠ¹ Š”тŠ¾Ń€Š¾Š¶ŠµŠ², e-Legion
Ā«Objective-C Runtime Š² ŠæрŠøŠ¼ŠµŃ€Š°Ń…Ā» ā€” ŠŠ»ŠµŠŗсŠµŠ¹ Š”тŠ¾Ń€Š¾Š¶ŠµŠ², e-Legion
Ā 

Viewers also liked

PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...Steve Lange
Ā 
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)PHX Session #5 : Architecture Without Big Design Up Front (Garibay)
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)Steve Lange
Ā 
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...Steve Lange
Ā 
Development Practices & The Microsoft Approach
Development Practices & The Microsoft ApproachDevelopment Practices & The Microsoft Approach
Development Practices & The Microsoft ApproachSteve Lange
Ā 
PHX Session #1: Development Best Practices And How Microsoft Helps
PHX Session #1: Development  Best  Practices And  How  Microsoft  HelpsPHX Session #1: Development  Best  Practices And  How  Microsoft  Helps
PHX Session #1: Development Best Practices And How Microsoft HelpsSteve Lange
Ā 
VSTS Architecture Edition Overview
VSTS Architecture Edition OverviewVSTS Architecture Edition Overview
VSTS Architecture Edition OverviewSteve Lange
Ā 

Viewers also liked (6)

PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
Ā 
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)PHX Session #5 : Architecture Without Big Design Up Front (Garibay)
PHX Session #5 : Architecture Without Big Design Up Front (Garibay)
Ā 
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
PHX Session #3 - "It Works on My Machine!" Closing the Loop Between Developme...
Ā 
Development Practices & The Microsoft Approach
Development Practices & The Microsoft ApproachDevelopment Practices & The Microsoft Approach
Development Practices & The Microsoft Approach
Ā 
PHX Session #1: Development Best Practices And How Microsoft Helps
PHX Session #1: Development  Best  Practices And  How  Microsoft  HelpsPHX Session #1: Development  Best  Practices And  How  Microsoft  Helps
PHX Session #1: Development Best Practices And How Microsoft Helps
Ā 
VSTS Architecture Edition Overview
VSTS Architecture Edition OverviewVSTS Architecture Edition Overview
VSTS Architecture Edition Overview
Ā 

Similar to Session #4: Treating Databases as First-Class Citizens in Development

TechDays Tunisia - Visual Studio & SQL Server, Better Together - Ayman El-Hattab
TechDays Tunisia - Visual Studio & SQL Server, Better Together - Ayman El-HattabTechDays Tunisia - Visual Studio & SQL Server, Better Together - Ayman El-Hattab
TechDays Tunisia - Visual Studio & SQL Server, Better Together - Ayman El-HattabAyman El-Hattab
Ā 
SQL Server Development Tools & Processes Using Visual Studio 2010
SQL Server Development Tools & Processes Using Visual Studio 2010 SQL Server Development Tools & Processes Using Visual Studio 2010
SQL Server Development Tools & Processes Using Visual Studio 2010 Ayman El-Hattab
Ā 
Introduction to SQL Antipatterns
Introduction to SQL AntipatternsIntroduction to SQL Antipatterns
Introduction to SQL AntipatternsKrishnakumar S
Ā 
Storage Methods for Nonstandard Data Patterns
Storage Methods for Nonstandard Data PatternsStorage Methods for Nonstandard Data Patterns
Storage Methods for Nonstandard Data PatternsBob Burgess
Ā 
Triggers and Stored Procedures
Triggers and Stored ProceduresTriggers and Stored Procedures
Triggers and Stored ProceduresTharindu Weerasinghe
Ā 
Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3Massimo Cenci
Ā 
Boost delivery stream with code discipline engineering
Boost delivery stream with code discipline engineeringBoost delivery stream with code discipline engineering
Boost delivery stream with code discipline engineeringMiro Wengner
Ā 
Interactive Kafka Streams
Interactive Kafka StreamsInteractive Kafka Streams
Interactive Kafka Streamsconfluent
Ā 
on SQL Managment studio(For the following exercise, use the Week 5.pdf
on SQL Managment studio(For the following exercise, use the Week 5.pdfon SQL Managment studio(For the following exercise, use the Week 5.pdf
on SQL Managment studio(For the following exercise, use the Week 5.pdfformaxekochi
Ā 
ę‰©å±•äø–ē•ŒäøŠęœ€å¤§ēš„图ē‰‡Blogē¤¾åŒŗ
ę‰©å±•äø–ē•ŒäøŠęœ€å¤§ēš„图ē‰‡Blogē¤¾åŒŗę‰©å±•äø–ē•ŒäøŠęœ€å¤§ēš„图ē‰‡Blogē¤¾åŒŗ
ę‰©å±•äø–ē•ŒäøŠęœ€å¤§ēš„图ē‰‡Blogē¤¾åŒŗyiditushe
Ā 
Fotolog: Scaling the World's Largest Photo Blogging Community
Fotolog: Scaling the World's Largest Photo Blogging CommunityFotolog: Scaling the World's Largest Photo Blogging Community
Fotolog: Scaling the World's Largest Photo Blogging Communityfarhan "Frank"ā€‹ mashraqi
Ā 
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMSM.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMSSupriya Radhakrishna
Ā 
Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Paulo Gandra de Sousa
Ā 
SQL Saturday 28 - .NET Fundamentals
SQL Saturday 28 - .NET FundamentalsSQL Saturday 28 - .NET Fundamentals
SQL Saturday 28 - .NET Fundamentalsmikehuguet
Ā 
A la dƩcouverte de TypeScript
A la dƩcouverte de TypeScriptA la dƩcouverte de TypeScript
A la dƩcouverte de TypeScriptDenis Voituron
Ā 
How do you create a programming language for the JVM?
How do you create a programming language for the JVM?How do you create a programming language for the JVM?
How do you create a programming language for the JVM?Federico Tomassetti
Ā 

Similar to Session #4: Treating Databases as First-Class Citizens in Development (20)

TechDays Tunisia - Visual Studio & SQL Server, Better Together - Ayman El-Hattab
TechDays Tunisia - Visual Studio & SQL Server, Better Together - Ayman El-HattabTechDays Tunisia - Visual Studio & SQL Server, Better Together - Ayman El-Hattab
TechDays Tunisia - Visual Studio & SQL Server, Better Together - Ayman El-Hattab
Ā 
SQL Server Development Tools & Processes Using Visual Studio 2010
SQL Server Development Tools & Processes Using Visual Studio 2010 SQL Server Development Tools & Processes Using Visual Studio 2010
SQL Server Development Tools & Processes Using Visual Studio 2010
Ā 
Introduction to SQL Antipatterns
Introduction to SQL AntipatternsIntroduction to SQL Antipatterns
Introduction to SQL Antipatterns
Ā 
Access 04
Access 04Access 04
Access 04
Ā 
Storage Methods for Nonstandard Data Patterns
Storage Methods for Nonstandard Data PatternsStorage Methods for Nonstandard Data Patterns
Storage Methods for Nonstandard Data Patterns
Ā 
Triggers and Stored Procedures
Triggers and Stored ProceduresTriggers and Stored Procedures
Triggers and Stored Procedures
Ā 
Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3
Ā 
Old code doesn't stink
Old code doesn't stinkOld code doesn't stink
Old code doesn't stink
Ā 
Boost delivery stream with code discipline engineering
Boost delivery stream with code discipline engineeringBoost delivery stream with code discipline engineering
Boost delivery stream with code discipline engineering
Ā 
Interactive Kafka Streams
Interactive Kafka StreamsInteractive Kafka Streams
Interactive Kafka Streams
Ā 
Linq
LinqLinq
Linq
Ā 
on SQL Managment studio(For the following exercise, use the Week 5.pdf
on SQL Managment studio(For the following exercise, use the Week 5.pdfon SQL Managment studio(For the following exercise, use the Week 5.pdf
on SQL Managment studio(For the following exercise, use the Week 5.pdf
Ā 
ę‰©å±•äø–ē•ŒäøŠęœ€å¤§ēš„图ē‰‡Blogē¤¾åŒŗ
ę‰©å±•äø–ē•ŒäøŠęœ€å¤§ēš„图ē‰‡Blogē¤¾åŒŗę‰©å±•äø–ē•ŒäøŠęœ€å¤§ēš„图ē‰‡Blogē¤¾åŒŗ
ę‰©å±•äø–ē•ŒäøŠęœ€å¤§ēš„图ē‰‡Blogē¤¾åŒŗ
Ā 
Fotolog: Scaling the World's Largest Photo Blogging Community
Fotolog: Scaling the World's Largest Photo Blogging CommunityFotolog: Scaling the World's Largest Photo Blogging Community
Fotolog: Scaling the World's Largest Photo Blogging Community
Ā 
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMSM.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
M.TECH 1ST SEM COMPUTER SCIENCE ADBMS LAB PROGRAMS
Ā 
PoEAA by Example
PoEAA by ExamplePoEAA by Example
PoEAA by Example
Ā 
Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)Patterns of Enterprise Application Architecture (by example)
Patterns of Enterprise Application Architecture (by example)
Ā 
SQL Saturday 28 - .NET Fundamentals
SQL Saturday 28 - .NET FundamentalsSQL Saturday 28 - .NET Fundamentals
SQL Saturday 28 - .NET Fundamentals
Ā 
A la dƩcouverte de TypeScript
A la dƩcouverte de TypeScriptA la dƩcouverte de TypeScript
A la dƩcouverte de TypeScript
Ā 
How do you create a programming language for the JVM?
How do you create a programming language for the JVM?How do you create a programming language for the JVM?
How do you create a programming language for the JVM?
Ā 

More from Steve Lange

Visual Studio ALM 2013 - Edition Comparison
Visual Studio ALM 2013 - Edition ComparisonVisual Studio ALM 2013 - Edition Comparison
Visual Studio ALM 2013 - Edition ComparisonSteve Lange
Ā 
Team Foundation Server 2012 Reporting
Team Foundation Server 2012 ReportingTeam Foundation Server 2012 Reporting
Team Foundation Server 2012 ReportingSteve Lange
Ā 
A Deeper Look at Team Foundation Server 2012 Version Control
A Deeper Look at Team Foundation Server 2012 Version ControlA Deeper Look at Team Foundation Server 2012 Version Control
A Deeper Look at Team Foundation Server 2012 Version ControlSteve Lange
Ā 
Upgrading to TFS 2010
Upgrading to TFS 2010Upgrading to TFS 2010
Upgrading to TFS 2010Steve Lange
Ā 
Microsoft ALM Platform Overview
Microsoft ALM Platform OverviewMicrosoft ALM Platform Overview
Microsoft ALM Platform OverviewSteve Lange
Ā 
Team Foundation Server - Tracking & Reporting
Team Foundation Server - Tracking & ReportingTeam Foundation Server - Tracking & Reporting
Team Foundation Server - Tracking & ReportingSteve Lange
Ā 
Visual Studio 2010 Testing for Developers
Visual Studio 2010 Testing for DevelopersVisual Studio 2010 Testing for Developers
Visual Studio 2010 Testing for DevelopersSteve Lange
Ā 
Visual Studio LightSwitch (Beta 1) Overview
Visual Studio LightSwitch (Beta 1) OverviewVisual Studio LightSwitch (Beta 1) Overview
Visual Studio LightSwitch (Beta 1) OverviewSteve Lange
Ā 
Team Foundation Server 2010 - Overview
Team Foundation Server 2010 - OverviewTeam Foundation Server 2010 - Overview
Team Foundation Server 2010 - OverviewSteve Lange
Ā 
Visual Studio 2010 Testing Overview
Visual Studio 2010 Testing OverviewVisual Studio 2010 Testing Overview
Visual Studio 2010 Testing OverviewSteve Lange
Ā 
TFS 2010: Team Development on Crack
TFS 2010: Team Development on CrackTFS 2010: Team Development on Crack
TFS 2010: Team Development on CrackSteve Lange
Ā 
Team Foundation Server 2010 - Version Control
Team Foundation Server 2010 - Version ControlTeam Foundation Server 2010 - Version Control
Team Foundation Server 2010 - Version ControlSteve Lange
Ā 
Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Steve Lange
Ā 
PHX Session #6: More Bang for Your Buck: Getting the Most out of Team Foundat...
PHX Session #6: More Bang for Your Buck: Getting the Most out of Team Foundat...PHX Session #6: More Bang for Your Buck: Getting the Most out of Team Foundat...
PHX Session #6: More Bang for Your Buck: Getting the Most out of Team Foundat...Steve Lange
Ā 
PHX - Session #4 Treating Databases as First-Class Citizens in Development
PHX - Session #4 Treating Databases as First-Class Citizens in DevelopmentPHX - Session #4 Treating Databases as First-Class Citizens in Development
PHX - Session #4 Treating Databases as First-Class Citizens in DevelopmentSteve Lange
Ā 
Big Event Looping Deck
Big Event Looping DeckBig Event Looping Deck
Big Event Looping DeckSteve Lange
Ā 
Session #6: Get More Bang For Your Buck
Session #6: Get More Bang For Your BuckSession #6: Get More Bang For Your Buck
Session #6: Get More Bang For Your BuckSteve Lange
Ā 
Session #1: Development Practices And The Microsoft Approach
Session #1: Development Practices And The Microsoft ApproachSession #1: Development Practices And The Microsoft Approach
Session #1: Development Practices And The Microsoft ApproachSteve Lange
Ā 
Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...
Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...
Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...Steve Lange
Ā 
Session #2: Test Driven Development
Session #2: Test Driven DevelopmentSession #2: Test Driven Development
Session #2: Test Driven DevelopmentSteve Lange
Ā 

More from Steve Lange (20)

Visual Studio ALM 2013 - Edition Comparison
Visual Studio ALM 2013 - Edition ComparisonVisual Studio ALM 2013 - Edition Comparison
Visual Studio ALM 2013 - Edition Comparison
Ā 
Team Foundation Server 2012 Reporting
Team Foundation Server 2012 ReportingTeam Foundation Server 2012 Reporting
Team Foundation Server 2012 Reporting
Ā 
A Deeper Look at Team Foundation Server 2012 Version Control
A Deeper Look at Team Foundation Server 2012 Version ControlA Deeper Look at Team Foundation Server 2012 Version Control
A Deeper Look at Team Foundation Server 2012 Version Control
Ā 
Upgrading to TFS 2010
Upgrading to TFS 2010Upgrading to TFS 2010
Upgrading to TFS 2010
Ā 
Microsoft ALM Platform Overview
Microsoft ALM Platform OverviewMicrosoft ALM Platform Overview
Microsoft ALM Platform Overview
Ā 
Team Foundation Server - Tracking & Reporting
Team Foundation Server - Tracking & ReportingTeam Foundation Server - Tracking & Reporting
Team Foundation Server - Tracking & Reporting
Ā 
Visual Studio 2010 Testing for Developers
Visual Studio 2010 Testing for DevelopersVisual Studio 2010 Testing for Developers
Visual Studio 2010 Testing for Developers
Ā 
Visual Studio LightSwitch (Beta 1) Overview
Visual Studio LightSwitch (Beta 1) OverviewVisual Studio LightSwitch (Beta 1) Overview
Visual Studio LightSwitch (Beta 1) Overview
Ā 
Team Foundation Server 2010 - Overview
Team Foundation Server 2010 - OverviewTeam Foundation Server 2010 - Overview
Team Foundation Server 2010 - Overview
Ā 
Visual Studio 2010 Testing Overview
Visual Studio 2010 Testing OverviewVisual Studio 2010 Testing Overview
Visual Studio 2010 Testing Overview
Ā 
TFS 2010: Team Development on Crack
TFS 2010: Team Development on CrackTFS 2010: Team Development on Crack
TFS 2010: Team Development on Crack
Ā 
Team Foundation Server 2010 - Version Control
Team Foundation Server 2010 - Version ControlTeam Foundation Server 2010 - Version Control
Team Foundation Server 2010 - Version Control
Ā 
Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)
Ā 
PHX Session #6: More Bang for Your Buck: Getting the Most out of Team Foundat...
PHX Session #6: More Bang for Your Buck: Getting the Most out of Team Foundat...PHX Session #6: More Bang for Your Buck: Getting the Most out of Team Foundat...
PHX Session #6: More Bang for Your Buck: Getting the Most out of Team Foundat...
Ā 
PHX - Session #4 Treating Databases as First-Class Citizens in Development
PHX - Session #4 Treating Databases as First-Class Citizens in DevelopmentPHX - Session #4 Treating Databases as First-Class Citizens in Development
PHX - Session #4 Treating Databases as First-Class Citizens in Development
Ā 
Big Event Looping Deck
Big Event Looping DeckBig Event Looping Deck
Big Event Looping Deck
Ā 
Session #6: Get More Bang For Your Buck
Session #6: Get More Bang For Your BuckSession #6: Get More Bang For Your Buck
Session #6: Get More Bang For Your Buck
Ā 
Session #1: Development Practices And The Microsoft Approach
Session #1: Development Practices And The Microsoft ApproachSession #1: Development Practices And The Microsoft Approach
Session #1: Development Practices And The Microsoft Approach
Ā 
Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...
Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...
Session #3: "It Works on My Machine!" Closing the Loop Between Development & ...
Ā 
Session #2: Test Driven Development
Session #2: Test Driven DevelopmentSession #2: Test Driven Development
Session #2: Test Driven Development
Ā 

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
Ā 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
Ā 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
Ā 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
Ā 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
Ā 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
Ā 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
Ā 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
Ā 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
Ā 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel AraĆŗjo
Ā 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
Ā 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
Ā 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
Ā 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
Ā 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
Ā 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
Ā 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
Ā 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
Ā 

Recently uploaded (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Ā 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
Ā 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
Ā 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Ā 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
Ā 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Ā 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
Ā 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Ā 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Ā 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
Ā 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Ā 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Ā 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
Ā 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
Ā 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Ā 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
Ā 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Ā 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Ā 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Ā 

Session #4: Treating Databases as First-Class Citizens in Development

  • 1. Treating Databases as First- Class Citizens in Development Rob Bagby Developer Evangelist Microsoft Corporation www.RobBagby.com Rob.Bagby@Microsoft.com
  • 2. Agenda Overview The Database Project (Test) Data Generation Unit Tests Managing Change Q&A
  • 3. Some Important Questions ā€¢ Where is the ā€œtruthā€ for my schema? ā€“ Production? ā€“ What about bug fixes? ā€“ What about version next? How do I version my databases? ā€¢ What do I do for test data? ā€¢ How do I test my database logic? ā€¢ What tools do I use to differentiate ā€¢ schemas, data?
  • 4. Challenge Solution ā€¢ Multiple Truths, stored ā€¢ Whereā€™s the truth? offline ā€¢ The same way I version ā€¢ How do I version? source code ā€¢ Where do I get test data? ā€¢ Test Data Generator ā€¢ How do I unit test? ā€¢ The same way I test source code (with a little SQL love thrown in) ā€¢ What tools do I have to ā€¢ Schema Compare, Data manage change? Compare, Refactoring
  • 5. The ā€œTruthā€ of my schema ā€¢ The production DB is only 1 version of the truth of your schema ā€¢ There may be bug fixes in Q/A right now, waiting deployment ā€¢ There may be development going on right now by multiple developers / teams
  • 6. Project Model ā€¢ The database project represents the ā€œtruthā€ of your schema ā€¢ The project contains the schema (*.sql files) ā€¢ Use version control to manage different versions
  • 7. Database Development Lifecycle SQL Server Database Database Project Database Project Template SQL Script
  • 8. Database Development Lifecycle Edit Refactor Compare Deploy Build Database Project Data Gen Test Compare
  • 9. Version Control Challenge class class class AuctionApplication AuctionApplication AuctionApplication App ( ( ( int id; id; int int id; void MethodA(); void MethodA(); string cacheTitle; void MethodB(); void MethodA(); ) ) void MethodB(); ) V3 Revision History V2 V1 CREATE TABLE dbo.Auction ALTER ALTER TABLE dbo.Auction TABLE dbo.Auction Database ( WITH CHECK CHECK ADD CONSTRAINT WITH ADD CONSTRAINT id INT NOT NULL, KEY (id) Au_PK Au_SK UNIQUE (name) PRIMARY name VARCHAR(25) NOT NULL, start DATETIME NULL, len INT NULL )
  • 10. Manual Versioning -- version 1 Add table dbo.Auction IF OBJECT_ID (N'dbo.Auction', N'U') IS NULL BEGIN CREATE TABLE dbo.Auction ( id INT NOT NULL, name VARCHAR(25) NOT NULL, start DATETIME NULL, len INT NULL ) END -- version 2 Add PK Au_PK IF NOT EXISTS (SELECT * FROM sys.key_constraints WHERE name = 'Au_PK' AND type = 'PK') BEGIN ALTER TABLE Auction WITH CHECK ADD CONSTRAINT Au_PK PRIMARY KEY (id) END -- version 3 Add UC Au_SK IF NOT EXISTS (SELECT * FROM sys.key_constraints WHERE name = 'Au_SK' AND type = ā€˜UQ') BEGIN ALTER TABLE Auction WITH CHECK ADD CONSTRAINT Au_SK UNIQUE (name) END
  • 11. Version Control The ā€œData dudeā€ approach class class class AuctionApplication AuctionApplication AuctionApplication App ( ( ( int id; id; int int id; void MethodA(); void MethodA(); string cacheTitle; ) void MethodB(); void MethodA(); ) void MethodB(); ) V2 V3 Revision History V1 CREATE TABLE TABLE TABLE dbo.Auction CREATE dbo.Auction CREATE dbo.Auction Logical ( ( ( Database id id INT NOT NULL, NULL PRIMARY KEY, KEY, id INT NOT NOT NULL PRIMARY INT name name name VARCHAR(25) NOT NULL UNIQUE, VARCHAR(25) NOT NULL, NULL, VARCHAR(25) NOT start start start DATETIME NULL, DATETIME NULL, NULL, DATETIME len len NULL NULL NULL INT len INT INT ) ) )
  • 12. Deployment The ā€œData dudeā€ approach CREATE TABLE TABLE TABLE dbo.Auction CREATE dbo.Auction CREATE dbo.Auction Logical ( ( ( Database id id INT NOT NULL, NULL PRIMARY KEY, KEY, id INT NOT NOT NULL PRIMARY INT name name name VARCHAR(25) NOT NULL UNIQUE, VARCHAR(25) NOT NULL, NULL, VARCHAR(25) NOT start start start DATETIME NULL, DATETIME NULL, NULL, DATETIME len len NULL NULL NULL INT len INT INT ) ) ) V2 V3 Revision History V1 New Incremental CREATE TABLE dbo.Auction ALTER TABLE dbo.Auction Deployment Deployment ( WITH CHECK ADD CONSTRAINT id INT NOT NULL PRIMARY KEY, Au_SK UNIQUE (name) name VARCHAR(25) NOT NULL UNIQUE, start DATETIME NULL, len INT NULL )
  • 14. Agenda Overview The Database Project (Test) Data Generation Unit Tests Managing Change Q&A
  • 15. Test Data Q & A ā€¢ Why not production data? ā€“ Ahhh, it may be illegal ā€“ Doesnā€™t test edge cases ā€“ Doesnā€™t address schema changes ā€¢ What are our test data requirements? ā€“ ā€œRandomā€ ā€“ Deterministic ā€“ Appropriately distributed ā€“ā€¦
  • 16. Test Data Q & A (continued) ā€¢ What are the differing needs for test data? ā€“ Functional Test ā€“ Load Test ā€¢ What are the versioning implications ā€“ We need differing plan(s) for differing schemas ā€“ We need to version plans along side schemas
  • 17. (Test) Data Generation in VSTS Choose the following ā€¢ The Tables ā€¢ Number of rows (RowCount ratios help) ā€¢ The generator for each column Out of the box: string, RegEx, data bound, etc. ā€“ Write your own ā€“ Set generator-specific settings ā€“ Set the seed ā€“ provides determinism ā€“ ā€¢ The distribution
  • 18. demo (Test) Data Generation
  • 19. Agenda Overview The Database Project (Test) Data Generation Unit Tests Managing Change Q&A
  • 20. Database Unit Testing ā€¢ Automatically generate unit test 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 and Post Test Scripts
  • 21. Database Unit Testing ā€¢ 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
  • 23. Agenda Overview The Database Project (Test) Data Generation Unit Tests Managing Change Q&A
  • 24. What kind of change can we manage? ā€¢ Refactoring ā€¢ Compare schemas ā€¢ Compare data