Get Your Database Under Control
-
Upload
grant-fritchey -
Category
Software
-
view
228 -
download
3
description
Transcript of Get Your Database Under Control
![Page 1: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/1.jpg)
Grant Fritchey | Red Gate Software
Team-based Development with
Version Control
![Page 3: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/3.jpg)
Goals
• Understand the value of version/source control for databases
• Learn the tools, standards, patterns and best practices needed to manage a database from source control
• Identify the necessary flow within a team needed to develop a database with source control
3
![Page 4: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/4.jpg)
HOW MANY OF YOU USE VERSION CONTROL FOR YOURAPPLICATION CODE?
C#, ASP.NET, Javascript, VB.NET, etc.
4
![Page 5: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/5.jpg)
HOW MANY OF YOU USE VERSION CONTROL FOR YOURAPPLICATION CODE?database
5
![Page 6: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/6.jpg)
Developers who refuse to use source/version
control should be fired, simple as that.
6
![Page 7: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/7.jpg)
Isn’t this too much trouble for my crappy
experimental program?
7
![Page 8: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/8.jpg)
Use source control because neither you nor
your developers are perfect.
8
![Page 9: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/9.jpg)
There are no excuses where you should
not use it.
9
![Page 10: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/10.jpg)
If it’s not in source control, it doesn’t exist.
10
![Page 11: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/11.jpg)
“…your database should always
be under source control right
next to your application code.”
11
![Page 12: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/12.jpg)
12
![Page 13: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/13.jpg)
Reducing Risk
13
![Page 14: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/14.jpg)
You’re using version control
14
![Page 15: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/15.jpg)
You’re using version control
15
![Page 16: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/16.jpg)
Use Something
16
![Page 17: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/17.jpg)
GETTING STARTED WITH DATABASES IN VCS
Demo
17
![Page 18: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/18.jpg)
Additional Reasons for Source Control
• Backup & Restore
• Undo
• Audit changes
• Sandbox
• Branching/Merging
18
![Page 19: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/19.jpg)
Rules for Database Development
19
Never use a shared database for development.
Always Have a Single, Authoritative Source
For Your Schema.
Always Version Your Database.
![Page 20: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/20.jpg)
Dedicated or Shared Databases?
20
![Page 21: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/21.jpg)
Shared databases are not wrong
21
![Page 22: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/22.jpg)
The Ideal
• Each developer has a dedicated environment with a copy of the schema and minimal data.
• A shared integration environment where all developers’ changes are merged, available for developer testing.
22
![Page 23: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/23.jpg)
Naming Standards
• Usually vary by company
• ISO 1179
• Be consistent
• Use tools for enforcement (SQLCop)
• Document these lightly and JIT
23
![Page 24: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/24.jpg)
Style Standards
• Vary by individual
• Make code more readable.
• Use tools to re-format code to your liking.
– SQL Prompt
– SSMS Tools Pack
– Others
24
![Page 25: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/25.jpg)
Teamwork
25
![Page 26: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/26.jpg)
Teamwork
• Communication
– Team members need to be aware of (easily) what
others are doing.
• Coordination
– Teams need to work in a way that complements
each other.
26
![Page 27: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/27.jpg)
THE FLOW WITHIN TEAMSDemo
27
![Page 28: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/28.jpg)
Automation is Best
28
![Page 29: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/29.jpg)
Use Automation
• Development systems and tools need to work
for the team, not against them.
• Many IDEs and tools work well in team
environments, if you configure them.
29
![Page 30: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/30.jpg)
Get All Your Code
• Object DDL
• Assembly code
• Security code
• Configuration settings
• Jobs
• Lookup data
30
![Page 31: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/31.jpg)
AUTOMATIONDemo
31
![Page 32: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/32.jpg)
Best Practices
• Use version control for all code (including tests)
• Commit early, commit often
• Use tools
– If it’s hard, people don’t do it
• Train people
• Build often
32
![Page 33: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/33.jpg)
Automation
![Page 34: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/34.jpg)
Automation
deployment package
![Page 35: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/35.jpg)
deployment package
1
2
3Back to
Development
FAIL
FAIL
FAIL
![Page 36: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/36.jpg)
References
• http://stackoverflow.com/questions/115369/do-you-use-source-control-for-your-database-items
• http://www.codinghorror.com/blog/archives/001050.html
• http://www.codinghorror.com/blog/2008/02/get-your-database-under-version-control.html
• http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterSQLServerDatabases.aspx
• http://odetocode.com/blogs/scott/archive/2008/01/30/three-rules-for-database-work.aspx
• Check in early, check in often -http://www.codinghorror.com/blog/2008/08/check-in-early-check-in-often.html
• http://betterexplained.com/articles/a-visual-guide-to-version-control/
36
![Page 37: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/37.jpg)
37
A big thank you to our sponsors
Gold Partners
Silver & Track Partners
Platinum Partners
![Page 38: Get Your Database Under Control](https://reader033.fdocuments.us/reader033/viewer/2022061117/546757d7af79597c418b4b65/html5/thumbnails/38.jpg)
38
A big thank you to our sponsors
Gold Partners
Silver & Track Partners
Platinum Partners