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
 
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
 
«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
 

Similar to PHX - 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
 
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 PHX - 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
 
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)
 
PoEAA by Example
PoEAA by ExamplePoEAA by Example
PoEAA 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 #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 #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 #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 #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
 
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
 
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
 

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 #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 #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 #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 #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
 
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...
 
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
 

Recently uploaded

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Recently uploaded (20)

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

PHX - 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