VS DBPro

668 views
547 views

Published on

Database development is unique due to its dependency on data. We can't just throw away old data and not allow for backward compatibility. However until recently the toolset for managing database code and allowing for things such as refactoring, code analysis and unit testing has been sorely lacking. Within the last 5 years the tools have matured to allow for structured database development. Let's take a look at Visual Studio Database Professional to see how.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
668
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Bio:Aaron has over 12 years of SQL Server experience. He is strong in database design & development, also having extensive experience in SSIS, SSRS, and administration, including performance, migrations and replication. Aaron is a MCITP in 2005 and 2008 as well as having a Masters in Information Systems Management. Aaron currently works for Magenic, a leading provider in innovative custom application development services as a Principal Consultant.Abstract:Database development is unique due to its dependency on data. We can't just throw away old data and not allow for backward compatibility. However until recently the toolset for managing database code and allowing for things such as refactoring, code analysis and unit testing has been sorely lacking. Within the last 5 years the tools have matured to allow for structured database development. Let's take a look at Visual Studio Database Professional to see how.
  • VS DBPro

    1. 1. Database Development using Visual Studio Database Professional 1© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    2. 2. Who am I? • Aaron Lowe – Senior Consultant – 12 years SQL Server experience – MCITP 2005 and 2008 – Co-organizer of SQLSaturday Chicago – Masters in Information Systems Management – www.aaronlowe.net – @Vendoran – http://sqlpeople.net/admin/2011/06/06/aaron-lowe/ 2© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    3. 3. Agenda • Development • Testing • Security • Deployment • Limitations 3© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    4. 4. Development Topics • Code Organization • Writing • Analysis • Project Types • Source Control 4© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    5. 5. Code Organization • Solution Explorer – Every T-SQL Object is a separate file – Manage the files • Schema View – Organized logically similar to SSMS – Manage the objects 5© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    6. 6. Writing • Based on CREATE statements • IntelliSense Enabled • Color Coded • Hover over to see data types • Code Stubs – C:Program Files (x86)Microsoft Visual Studio 10.0VSTSDBExtensionsSqlServerItems • Security managed independently 6© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    7. 7. Writing cont. • Dependencies – System Databases – Server Project – SQLCLR Projects • Refactors – Rename  Object  Server or database reference – Move  Objects between schemas – Quality  Fully qualify database objects  Expand wildcards characters in SELECT 7© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    8. 8. Analysis • 15 Built in code analysis rules – Can treat as Warning or error – Extendable 8© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    9. 9. Project Types • Database Project • Server Project • CLR • Test Projects!!! • Data-tier Application 9© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    10. 10. Source Control • Visual Studio Source Control • Check/in – Check/out • Versioning History 10© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    11. 11. Agenda • Development • Testing • Security • Deployment • Limitations 11© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    12. 12. Testing Topics • Data Generation • Unit Testing 12© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    13. 13. Data Generation Generates random values based upon Data Type appropriate data type Generates a value that is selected from a pre- determined data source. The data is randomly DataBound selected from the data source after the returned dataset is cached.. Generates a random Unicode string that Regular matches a predefined regular expression. For Expression more information about this generator, see The Regular Expression Generator. 13© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    14. 14. Unit Testing Fails if the checksum of the result set returned Data Checksum from the Transact-SQL script does not match the expected checksum. Fails if the result set returned from the Empty ResultSet Transact-SQL script is not empty. Fails if the Transact-SQL test script takes longer Execution Time than expected to execute. Fails if the columns and data types of the result Expected Schema set do not match those specified for the test condition. Not Empty Fails if the result set is empty. ResultSet Fails if the result set does not contain the Row Count expected number of rows. Fails if a particular value in the result set does Scalar Value not equal the specified value. 14© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    15. 15. Agenda • Development • Testing • Security • Deployment • Limitations 15© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    16. 16. Security Topics • Server Login • Database User • Database Role • Role Membership • Object Permissions 16© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    17. 17. Server Login • Windows Auth • SQL Server Auth • Default Database set within Database Project via Post- Deployment Script ALTER LOGIN [TestLogin] WITH DEFAULT_DATABASE= [$(DatabaseName)] 17© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    18. 18. Database User • CREATE USER [] FOR LOGIN [] – Requires Server project reference 18© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information 18
    19. 19. Database Role • CREATE Role 19© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information 19
    20. 20. Role Membership • New project doesn’t include the file, must be manually created • Can be located anywhere in solution and called anything • When revered engineered it’s Under Schema Objects and called [ProjectName].rolememberships.sql 20© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information 20
    21. 21. Object Permissions • Very much a Pain!! • XML Format • Database.sqlpermissions 21© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information 21
    22. 22. Agenda • Development • Testing • Security • Deployment • Limitations 22© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    23. 23. Deployment Topics • Database Options • Deployment Options • Deployment scripts • Schema Comparison • Data Comparison 23© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    24. 24. Database Options • Collation • DB Options (statistics, close, shrink) • ANSI options • Compat Level • Services Broker • Recovery • Page Verify • Change Tracking • etc 24© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information 24
    25. 25. Deployment Options • Database properties • Re-create database • Block data loss • Single User Mode • Advanced Options – Abort on first Error – Ignore (column order, etc.) – Checks (New Constraints, etc.) – Drop (Indexes, Constraints, etc.) 25© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    26. 26. Deployment Scripts • Pre and Post Deployment • Can call other scripts via r: 26© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    27. 27. Schema Comparison DEMO 27© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    28. 28. Data Comparison DEMO 28© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    29. 29. Limitations • Server Roles • Replication • CDC • Log Shipping • Mirroring • Other DBA specific objects/tasks 29© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information
    30. 30. Thank you • Other resources – Visual Studio Database Guide  http://vsdatabaseguide.codeplex.com/ – Blogs  http://blogs.msdn.com/b/gertd/  http://blogs.msdn.com/b/bahill/  http://blogs.msdn.com/b/psirr/  http://blogs.msdn.com/b/vstsdb/ – Forum  http://social.msdn.microsoft.com/Forums/en-US/vstsdb/threads • Q&A 30© Magenic Technologies, Inc. 2011 Confidential and Proprietary Information

    ×