+ All Categories
Home > Documents > SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best...

SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best...

Date post: 05-Jun-2018
Category:
Upload: hanhi
View: 224 times
Download: 2 times
Share this document with a friend
21
SQL Server Database Development Best Practices Grant Fritchey, Red Gate Software [email protected] Jeremy Kadlec, Edgewood Solutions [email protected]
Transcript
Page 1: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

SQL Server Database Development Best Practices

Grant Fritchey, Red Gate Software [email protected] Jeremy Kadlec, Edgewood Solutions [email protected]

Page 2: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

Agenda

Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved 2

• Introductions

• Best Practices

– Design, Build, Test, Deploy, Tools

• Demos

• Q&A and Thank You

• Special offer for all attendees

Page 3: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

Grant Fritchey • Product Evangelist for Red Gate Software

• Microsoft SQL Server MVP

• Author: – SQL Server Execution Plans

– SQL Server 2008 Query Performance Tuning Distilled

– SQL Server MVP Deep Dives II

Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved 3

Page 4: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

Jeremy Kadlec • Edgewood Solutions - CTO

[email protected] • 410.591.4683

• MSSQLTips.com - Co-Founder • Twitter - @MSSQLTips • LinkedIn -

http://www.linkedin.com/ groups/MSSQLTips-2320891

• Baltimore SQL Server Users Group - Co-Leader • www.bssug.org

• SQL Server MVP

4 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Page 5: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

Design Best Practices

5 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Build a Strong Foundation

Comprehensive Data Modeling

Right Technology @ Right Time

Page 6: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

#1 – Build a Strong Foundation

Forward Thinking

• Business Goals

• Long Term Needs

Scope & Support

• Managerial Support

• Reasonable Expectations

Cohesive Team

• Correct Skills and Training

• Accountability

Stable Platform

• Appropriate Technology

• Meet Performance Needs

Complete Requirements

• Correct Level of Detail

• Agreement

6 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Page 7: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

#2 – Comprehensive Data Model

Flexibility Scalability

Growth

• Set the standard - Build a Data Modeling Checklist for your company • Make the Data Dictionary mandatory

• Store meta data in your SQL Server database • Include object, column, relationships, sample data, etc. • Maintain with your releases

• Include in code reviews and source control

7 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Page 8: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

#3 - Right Technology @ Right Time

Plan Options

Proof of Concept

Experience

• Holistic view

• Build technical plan

• Seek alternatives

• Mitigate risk with new technologies

– Proof of concept

• Pull from experience

• Document and discuss with team

8 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Page 9: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

Build Best Practices

9 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Leverage Your Sandbox Environment

Build on Your Experience

Prioritize Security

Page 10: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

#4 – Leverage Your Sandbox Environment

• Functional environment to match production

• Ability to setup quickly and begin development

• Intended for personal or small group usage

• Ability to build and recreate as needed

• Isolated so no impact to other team members

Functional environment

to match production

Feature Enhancements

Greenfield Development

Prototype Development

10 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Page 11: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

#5 – Build on Your Experience

Naming conventions

Comment code

Parameters in tables

Consolidated error handling

Referential integrity, data types, indexes, etc.

Select correct technology

Review query plans

Code reviews

Check-in procedures

No functions in WHERE clause

Avoid cursors, temp tables, triggers, etc. when a better solution is available

No views on top of views on top of views

Don’t throw hardware at a database design problem

Verify code before check-in

No code susceptible to SQL Injection

11 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Page 12: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

#6 – Prioritize Security • “From 2005 through to September 20, 2011, SQLinjection has been

responsible for 83% of successful hacking-related data breaches.”

– http://blog.imperva.com/2011/09/sql-injection-by-the-numbers.html

• “…from 2005 to September 20, 2011. There were 312,437,487 data records lost due to hacking with about 262 million records from various breaches including TJMax, RockYou and Heartland, all of which were SQL injection attacks.”

– http://blog.imperva.com/2011/09/sql-injection-by-the-numbers.html

• “In the wild, it has been noted that applications experience, on average, 71 attempts an hour.[1] When under direct attack, some applications occasionally came under aggressive attacks and at their peak, were attacked 800–1300 times per hour.”

– http://en.wikipedia.org/wiki/SQL_injection#cite_note-blog.imperva.com-0

12 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Page 13: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

Test Best Practices

13 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Coordinate Parallel Development

Close the Loop

Page 14: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

#7 - Coordinate Parallel Development

Customer Object

Release 1.1

Hot Fix 1.1.1

Release 1.2.2

• Coordination requires communication, comments and notation • Prevent “Code Jambalaya“ from causing chaos and frustration

14 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Release Issues

Page 15: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

#8 - Close the Loop

15

Review Requirements

Build Test Cases

Development

Track Changes Verify

Requirements

Promote to Test

User Involvement

Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Page 16: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

Deployment Best Practices

16 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Avoid Deployment Catastrophes

Page 17: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

#9 – Avoid Deployment Catastrophes Don’t deploy suspect code, apply the brakes Don’t let any changes sneak into the environment Don’t assume things will just work out Don’t take someone’s word that code is accurate

Build rollback scripts as your insurance policy

Deploy the same scripts to Test as Production – Rollback deployment and re-

deploy until error free

Double check your deployment scripts for accuracy – Remember “Code Jambalaya“

Ensure deployment is verified, do not find out from users

17 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Page 18: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

Tools Best Practices

18 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Build Re-Useable Templates

Standardize Tools and Methods

Page 19: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

#10 – Build Re-Useable Templates • T-SQL Templates

– Integrate with SSMS

– Template projects

– Data dictionary

• Integration Services – Import processes

– Export processes

• Reporting Services – Connection objects

– Headers, footers, etc.

• Benefits – No “blank slate”

syndrome

– Standardization

– Set expectations

– Time saver

19 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Page 20: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

#11 – Standardize Tools and Methods

• Methods – Data Access

– Comments

– Deployment

– Rollback

– Communication

• SQL Server Tools – Development

– Continuous Integration

– Source Control

– Refactoring

20 Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved

Page 21: SQL Server Database Development Best Practices€¦ · SQL Server Database Development Best Practices ... Build a Data Modeling Checklist for your company ... database design problem

Next Steps Offer For all webinar registrants

SQL Source Control - $99

SQL Developer Bundle - $200 discount

Email [email protected]

Quote code “webinarmssqltipsmarch2012”

One offer per organization

red-gate.com

28-day free trial

14-day free trial


Recommended