Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

TechDays Tunisia - Visual Studio & SQL Server, Better Together - Ayman El-Hattab

1,288 views

Published on

TechDays Tunisia 2012 - Ayman El-Hattab, MVP

Published in: Technology
  • Be the first to comment

  • Be the first to like this

TechDays Tunisia - Visual Studio & SQL Server, Better Together - Ayman El-Hattab

  1. 1. Microsoft Most Valuable Professionalwww.aymanelhattab.comTwitter: @AymanElhattab
  2. 2. class AuctionApplication class AuctionApplication class AuctionApplication ( ( ( App int id; int id; int id; void MethodA(); void MethodA(); string cacheTitle; ) void MethodB(); void MethodA(); ) void MethodB(); )V1 V2 V3 Revision History CREATE ALTER TABLE dbo.Auction TABLE ALTER TABLE dbo.Auction dbo.Auction Database ( WITH CHECK ADD CONSTRAINT WITH CHECK ADD CONSTRAINT id INT NOT PRIMARY KEY (id) Au_PK Au_SK UNIQUE (name) NULL, name VARCHAR(25) NOT NULL, start DATETIME NULL, len INT NULL )
  3. 3. -- version 1 Add table dbo.AuctionIF OBJECT_ID (Ndbo.Auction, NU) IS NULLBEGINCREATE TABLE dbo.Auction( id INT NOT NULL, name VARCHAR(25) NOT NULL, start DATETIME NULL, len INT NULL)END-- version 2 Add PK Au_PKIF 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_SKIF 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
  4. 4. class AuctionApplication class AuctionApplication class AuctionApplication ( ( ( App int id; int id; int id; void MethodA(); void MethodA(); string cacheTitle; ) void MethodB(); void MethodA(); ) void MethodB(); ) Source-controlled and deployed scriptsV1 V2 V3 do not need to match! Revision History CREATE CREATE CREATE dbo.Auction TABLE dbo.Auction dbo.Auction TABLE TABLE Logical In- ( ( ( Memory id INT NOTid NOT NULL PRIMARY KEY, KEY, id INT NULL,INT NOT NULL PRIMARY Database name VARCHAR(25) NOT NULL, NULL, NULL UNIQUE, name VARCHAR(25) NOT name VARCHAR(25) NOT start DATETIME NULL, NULL, NULL, start DATETIME start DATETIME len INT NULL NULL NULL len INT len INT ) ) )
  5. 5. CREATE CREATE CREATE dbo.Auction TABLE dbo.Auction dbo.Auction TABLE TABLE Logical In- ( ( ( Memory id INT NOTid NOT NULL PRIMARY KEY, KEY, id INT NULL,INT NOT NULL PRIMARY Database name VARCHAR(25) NOT NULL, NULL, NULL UNIQUE, name VARCHAR(25) NOT name VARCHAR(25) NOT start DATETIME NULL, NULL, NULL, start DATETIME start DATETIME len INT NULL NULL NULL len INT len INT ) ) )V1 V2 V3 Revision History New Incremental Deployment CREATE TABLE dbo.Auction Deployment ALTER TABLE dbo.Auction ( WITH CHECK ADD CONSTRAINT id INT NOT NULL PRIMARY KEY, Au_SK UNIQUE (name) name VARCHAR(25) NOT NULL UNIQUE, start DATETIME NULL, V2 len INT NULL )
  6. 6. Background Analysis: Source Interpret, Database analyze and Reverse engineer validate schema into DDL artifacts Schema ModelDatabase Project Build .dbschema Schema Model fileDDL SQL Artifacts Compose model representation from source code fragments!
  7. 7. Target.dbschema Database file Schema Model Schema Model Model Diff Plan Executors .SQL Deployment Engine Incremental Target Update
  8. 8. TFS Source Control Check in toDBDevDBA Staging Database Database Import schema Production Project Database
  9. 9. •Sync Dev •Check-out Env •Edit/Refactor •Generate Test Data •Database Unit Test Dev •Check-in Env TFS •Work is being driven Dev and tracked via work items Env •Other team members can pick up changesDBDevDBA Staging Database TFS Shelving allows DBA Dev to provide guidance Env Production and evaluate work Database
  10. 10. Daily Test Build Database Output Can also be TFS used in a “Continuous” Get Latest build environmentDBDev Daily Build Test LabDBA Staging Database Production Database
  11. 11. TFS Sync from LabelDBDevDBA Deploy Staging Database SQL Database Deploy Production Project Build Script Database Verify Refine deploy script
  12. 12. http://s3.amazonaws.com/dnrtv/dnrtv_0176.wmvhttp://blogs.msdn.com/b/bahill/archive/2009/03/02/offline-schema-development.aspxhttp://msdn.microsoft.com/en-us/library/dd172133.aspxhttp://www.youtube.com/watch?v=JI7uiAQZHCghttp://msdn.microsoft.com/en-us/library/ms165034.aspx

×