SlideShare a Scribd company logo
1 of 47
Download to read offline
KYSUC
Keep Your Schema Under Control
04.FEV.2016
Nuno Alexandre Alves
Speaker
• Nuno Alves
• Born at Coimbra / Lives in Leiria
• Degree in Informatics Engineering (ESTG-IPLeiria)
• Some experience with databases
• Nowadays working in Critical Software, SA
nuno.alexandre.alves@gmail.com
nuno.alexandre.alves
Disclaimer
This presentation is:
• From my personal experience
• My own suggestions
This presentation is NOT to:
• Pointing fingers
• Enumerate errors
• This is better than that
• Do not use this
Just another day in “paradise”
• How do you develop your scripts ?
• Do you have a ER model of your Database(s) ?
• Do you have your Database documented ?
• How do you control your scripts versions ?
• Do you have your test data under scripts ?
• How do you test your scripts ?
• How do you deploy your application and
database to a specific version ?
Agenda
1. Goals
2. Diagrams (ER models)
3. Scripts
4. Deploy
5. Documentation
Goals for Today
• Updated ER model
• Scripts versioned
• Easy Deploy
• Easy Documentation
• Schema Under Control !
Agenda
1. Goals
2. Diagrams (ER models)
3. Scripts
4. Deploy
5. Documentation
ER Model (1/4)
Start New Project (from requirements)
• Build your Conceptual Model
• First Physical Model
• First Scripts (version 1.0.0)
• Print (paper not PDF) your Physical Model and put it
in a Wall next to the team (old-school but it works)
Assumptions:
• High Level Architecture designed
• RBDMS almost decided (for the first scripts)
ER Model (2/4)
Start New Project (already in PROD) / Maintenance
• Ask for actual documentation (get lucky )
• DDL of actual production database
• Import DDL in your development servers
• Reverse Engineering
• Build Conceptual Model (from Physical) if
necessary
• Script Physical Model with actual application
version (ex: v3.5.2 – it’s your baseline)
ER Model (3/4)
Development / Maintenance
• Keep your database changes updated in
your ER Model
• Use Reverse Engineering to do
checkpoints (compare)
ER Model (4/4)
Tools
• Use a Case Tool
• PowerDesigner
• Enterprise Architect
• …
Agenda
1. Goals
2. Diagrams (ER models)
3. Scripts
4. Deploy
5. Documentation
Scripts (1/10)
Scripts Development (projects reality)
• Manually
• I don’t have scripts. My ORM tool does it
for me !?!
• Database is something to store some data
on it. I don’t care.
Scripts (2/10)
Scripts Development (projects reality)
• WTF ?!
• Your medical records relies on a database system
• Your bank account relies on a database system
• Your salary relies on a database system
• …
• Your life relies on too many database systems
• Take your own conclusions
Scripts (3/10)
Then someday
• How do I execute the database scripts ? Order By ?
• Which development database is updated ?
• How do you develop scripts ?
• One script vs multiple scripts ?
• Full Scripts vs Partial Scripts ?
• It’s your ORM your Database developer ?
• Naming Conventions for objects (where is the guide?)
• I have a app log with this error “constraint SYS_098374
violated”. What is that constraint ?
• The column CGTRTHY stores what ?
Scripts (4/10)
Database Scripts Under Control
• Why ?
• Is your source code under control ?
• Does your source code have versions ?
• Database scripts = source code ?
• I think Yes !
• Table definition
• Table initial data
• Function / Stored Procedure / Package
Scripts (5/10)
Decide your Database Storage Strategy
• Check production for rolling projects
• Decide according to hosting supplier or client needs
• Tablespaces
• Data files
• File groups
My Suggestion (minimum)
• One Tablespace for Data
• One Tablespace for Indexes
• One Tablespace for LOBs
Scripts (6/10)
Decide your Database / Schema(s) architecture
• One schema, multiple users with diff grants
• Multiple schemas, one/multiple users
My Suggestion
• Keep it simple
• One schema/database, multiple users (grants/views)
• FKs between multiple schemas not supported in all RDBMS
• Distributed Transactions (do you really want ?!)
• Multiple queries (joins in app server)
• Are you creating your own RDBMS ?!
Scripts (7/10)
Decide your Database Naming Conventions
• Easy identify a database object
• Name every object in database
• Don’t let default names under RDBMS
Scripts (8/10)
Script like source code
• Use SQL formatting (for human readable)
• Comment your SQL
• Define objects language: PT; EN; FR … (don’t mix)
Script for documentation
• Comment every object (mandatory: wait and see)
• Keep documentation in database dictionary
• Useful for Reverse Engineering
• Useful for Automatic Documentation
• COMMENT ON TABLE
• COMMENT ON COLUMN TABLE_NAME.COLUMN_NAME
Scripts (9/10)
Tools
• Manually (Notepad, VI, … is your friend!)
• Liquibase
• mybatis
• MIGRATEdb
• migrate4j
• Flyway
• …
Scripts (10/10)
Scripts Under Control ?
Flyway (1/6)
Overview
• Scripts: SQL, Java
• RDBMS Agnostic (JDBC driver)
• Inside your source code
• Placeholders (variables)
• Multiple Execution Modes
• Java API
• Maven / Ant
• Command line
• Ex: V2_0_0_1_0001__script_name.sql
Flyway (2/6)
Decide your Script Naming Convention
• V<JIRA_FIX_VERSION>_1_<4_digits>__<JIRA_KEY>.sql
• <4_digitos>
• Execution order
Flyway (3/6)
Put some code in your Script
• Add an header to your SQL file
• Add JIRA_KEY or JIRA URL as a comment
• Commit
Flyway (4/6)
Decide your Execution Mode
• Command line (java -jar …)
• Maven/ANT
• configure inside your IDE or in CLI
• Use Maven profiles is necessary (useful in multiple
databases/environments)
Flyway (5/6)
Flyway in action
• flyway:info
• Check schema version already installed
• You need flyway:baseline for the first time
Flyway (6/6)
Flyway in action
• flyway:migration
• Script execution
• With/without target release
Flyway
In Action
Agenda
1. Goals
2. Diagrams (ER models)
3. Scripts
4. Deploy
5. Documentation
Deploy (1/7)
Deploy Database Scripts
• Do you test your scripts ? (how many times)
• Do you re-create your schema from scratch ?
• Do you have automatic deployment for your app ?
• And your database ?
• Do you have night builds ?
• They include database too ? and automated tests ?
• Do you simulate your client releases in development
environments ?
• Do you have confidence in your own scripts ?
Deploy (2/7)
Deploy Database (full / upgrade)
• Use your Continuous Integration
• Jenkins
• Team City
• Bamboo
• Other …
Deploy (3/7)
Jenkins + Flyway = easy database deploy
• Why Jenkins ?
• Easy to configure
• Parametrized builds
• Many plugins (CVS, SVN, Maven, JIRA, Email, …)
• Scheduler
• Live Build Logs / Console output directly in browser
• Why not ?!
Deploy (4/7)
Jenkins + Flyway = easy database deploy
• Configure a Jenkins Job
• Checkout script from VCS
• Put some parameters
• if necessary for customs build
• for multiple versions
• for multiple databases
• Execute Flyway
• via Maven
• via custom Shell Script / Windows batch
Jenkins + Flyway
In Action
Deploy (5/7)
Continuous Monitor your database
• Oracle Enterprise Manager (Oracle)
• pgwatch (PostgreSQL)
• db2top (DB2)
• SQL Server Management Studio (SQLServer)
• MySQL Enterprise Monitor (MySQL)
• …
• Check administrator views (available in every RDBMS)
Deploy (6/7)
Continuous Monitor your database
• Check some random SQL Statements
• CPU
• I/O
• Get query plan for these statements
• Help development team write better SQL
• Create indexes according to business needs
• Monitor sessions
• Check Connection Pooling parameters
• Min / Max Pool sizes (warn: multiple Connections Pools)
Deploy (7/7)
Help Development Team to help yourself
• Write SQL Statements to log (debug mode)
• Ask for log4jdbc / P6Spy / … (with parameters)
• Write query times to log
• Analyze top time consuming queries
• Analyze top running queries
• Ask for application times vs database times (in log)
• Most of times the application consumes more time (yes it’s true)
• Try to analyze how many queries are made for a business operation
• Check the number of columns retrieved in every query (it’s really necessary 80
columns ?)
Agenda
1. Goals
2. Diagrams (ER models)
3. Scripts
4. Deploy
5. Documentation
Documentation (1/3)
How do you produce your database documentation ?
• Manually
• I don’t have database documentation
• “My client doesn’t need this documentation”
• And your team ?
• How do you maintain a project without documentation?
• Most (~All) of your production tickets are resolved by SQL
statements !
• Client business data is stored in “your” database (really?!)
Documentation (2/3)
Automatic Documentation
• Use RDBMS data dictionary
• information_schema.tables, …
• user_tables, …
• syscat.tables, …
• Remember COMMENT ON … from scripts ?
• “Export” to something useful
• Word Document/PDF ?
• Who reads a 800 pages document ?
Documentation (3/3)
Automatic Documentation
• Perl script (reads data dictionary, outputs One HTML file)
• Send to your client as a deliverable
• Publish in your wiki
• Open locally in your browser
• Produce custom CSS: 30m - 1h
• Update Documentation: 1 minute
• Remember COMMENT ON 
Summary (from initial goals) (1/2)
ER Model
• Use a Case Tool
• Keep your model updated
Scripts versioned
• Use Flyway / Liquibase / Other
• Script everything (data tests included)
• Review your scripts
• Naming Conventions
• Comments
Summary (from initial goals) (2/2)
Easy Deploy
• Use Jenkins / Team City / Bamboo / Other
• Keep your database under Continuous Integration
• Schedule your database builds
• Parametrize your database deploy
• Monitor your database close
• Release Matrix isn’t nice to have (is mandatory)
Easy Documentation
• Comment your objects in data dictionary
Main Goal
Updated ER Model
+ Scripts versioned
+ Easy Deploy
+ Easy Documentation
= KYSUC
Extra Credits
Define / ask for backup/restore plan
• Test your backups (restore is your friend)
• Check backup/restore times
• Check database growth
Compare data
• Compare your production data with development data:
reference data
• Try to equal PKs IDs across environments (for referencial data)
That’s It!
Thank you for your time.

More Related Content

What's hot

Migrating to Java 11
Migrating to Java 11Migrating to Java 11
Migrating to Java 11Arto Santala
 
Digpen 7: Why choose Laravel?
Digpen 7: Why choose Laravel?Digpen 7: Why choose Laravel?
Digpen 7: Why choose Laravel?John Blackmore
 
Integration Testing Practice using Perl
Integration Testing Practice using PerlIntegration Testing Practice using Perl
Integration Testing Practice using PerlMasaki Nakagawa
 
CDI Best Practices with Real-Life Examples - TUT3287
CDI Best Practices with Real-Life Examples - TUT3287CDI Best Practices with Real-Life Examples - TUT3287
CDI Best Practices with Real-Life Examples - TUT3287Ahmad Gohar
 
Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and Ryan Cuprak
 
A Taste of Pharo 7.0
A Taste of Pharo 7.0A Taste of Pharo 7.0
A Taste of Pharo 7.0ESUG
 
Fun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJBFun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJBArun Gupta
 
Saving Time By Testing With Jest
Saving Time By Testing With JestSaving Time By Testing With Jest
Saving Time By Testing With JestBen McCormick
 
Social Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoSocial Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoPaul Withers
 
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!Serdar Basegmez
 
Backing Data Silo Atack: Alfresco sharding, SOLR for non-flat objects
Backing Data Silo Atack: Alfresco sharding, SOLR for non-flat objectsBacking Data Silo Atack: Alfresco sharding, SOLR for non-flat objects
Backing Data Silo Atack: Alfresco sharding, SOLR for non-flat objectsITD Systems
 
Play Framework: The Basics
Play Framework: The BasicsPlay Framework: The Basics
Play Framework: The BasicsPhilip Langer
 
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)Mihail Stoynov
 
Perl Testing Consideration (seen from other languages)
Perl Testing Consideration (seen from other languages)Perl Testing Consideration (seen from other languages)
Perl Testing Consideration (seen from other languages)Masaki Nakagawa
 
All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$Joe Ferguson
 
2021.laravelconf.tw.slides1
2021.laravelconf.tw.slides12021.laravelconf.tw.slides1
2021.laravelconf.tw.slides1LiviaLiaoFontech
 
Immutable infrastructure:觀念與實作 (建議)
Immutable infrastructure:觀念與實作 (建議)Immutable infrastructure:觀念與實作 (建議)
Immutable infrastructure:觀念與實作 (建議)William Yeh
 
JCConf 2015 Java Embedded and Raspberry Pi
JCConf 2015 Java Embedded and Raspberry PiJCConf 2015 Java Embedded and Raspberry Pi
JCConf 2015 Java Embedded and Raspberry Pi益裕 張
 

What's hot (20)

Migrating to Java 11
Migrating to Java 11Migrating to Java 11
Migrating to Java 11
 
Digpen 7: Why choose Laravel?
Digpen 7: Why choose Laravel?Digpen 7: Why choose Laravel?
Digpen 7: Why choose Laravel?
 
Integration Testing Practice using Perl
Integration Testing Practice using PerlIntegration Testing Practice using Perl
Integration Testing Practice using Perl
 
CDI Best Practices with Real-Life Examples - TUT3287
CDI Best Practices with Real-Life Examples - TUT3287CDI Best Practices with Real-Life Examples - TUT3287
CDI Best Practices with Real-Life Examples - TUT3287
 
Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and
 
A Taste of Pharo 7.0
A Taste of Pharo 7.0A Taste of Pharo 7.0
A Taste of Pharo 7.0
 
Fun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJBFun with EJB 3.1 and Open EJB
Fun with EJB 3.1 and Open EJB
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
 
Saving Time By Testing With Jest
Saving Time By Testing With JestSaving Time By Testing With Jest
Saving Time By Testing With Jest
 
Social Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoSocial Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and Domino
 
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
 
Backing Data Silo Atack: Alfresco sharding, SOLR for non-flat objects
Backing Data Silo Atack: Alfresco sharding, SOLR for non-flat objectsBacking Data Silo Atack: Alfresco sharding, SOLR for non-flat objects
Backing Data Silo Atack: Alfresco sharding, SOLR for non-flat objects
 
Play Framework: The Basics
Play Framework: The BasicsPlay Framework: The Basics
Play Framework: The Basics
 
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)
 
Perl Testing Consideration (seen from other languages)
Perl Testing Consideration (seen from other languages)Perl Testing Consideration (seen from other languages)
Perl Testing Consideration (seen from other languages)
 
All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$All the Laravel Things – Up & Running to Making $$
All the Laravel Things – Up & Running to Making $$
 
2021.laravelconf.tw.slides1
2021.laravelconf.tw.slides12021.laravelconf.tw.slides1
2021.laravelconf.tw.slides1
 
Immutable infrastructure:觀念與實作 (建議)
Immutable infrastructure:觀念與實作 (建議)Immutable infrastructure:觀念與實作 (建議)
Immutable infrastructure:觀念與實作 (建議)
 
History of Java 1/2
History of Java 1/2History of Java 1/2
History of Java 1/2
 
JCConf 2015 Java Embedded and Raspberry Pi
JCConf 2015 Java Embedded and Raspberry PiJCConf 2015 Java Embedded and Raspberry Pi
JCConf 2015 Java Embedded and Raspberry Pi
 

Viewers also liked

Development Horror Stories
Development Horror StoriesDevelopment Horror Stories
Development Horror StoriesRoberto Cortez
 
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7Roberto Cortez
 
Александр Захаров "Использование EntityGraph в JPA 2.1"
Александр Захаров "Использование EntityGraph в JPA 2.1"Александр Захаров "Использование EntityGraph в JPA 2.1"
Александр Захаров "Использование EntityGraph в JPA 2.1"Ciklum Minsk
 
33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmodwalkmod
 
Gwt presentation
Gwt presentationGwt presentation
Gwt presentation철민 배
 
Javascript & Angular .js for the enterprise, lessons learned, typescript scal...
Javascript & Angular .js for the enterprise, lessons learned, typescript scal...Javascript & Angular .js for the enterprise, lessons learned, typescript scal...
Javascript & Angular .js for the enterprise, lessons learned, typescript scal...David Amend
 
Challenges and best practices of database continuous delivery
Challenges and best practices of database continuous deliveryChallenges and best practices of database continuous delivery
Challenges and best practices of database continuous deliveryDBmaestro - Database DevOps
 
The Challenges & Pitfalls of Database Continuous Delivery
The Challenges & Pitfalls of Database Continuous DeliveryThe Challenges & Pitfalls of Database Continuous Delivery
The Challenges & Pitfalls of Database Continuous DeliveryPerforce
 
walkmod: how it works
walkmod: how it workswalkmod: how it works
walkmod: how it workswalkmod
 
Reasons to migrate to modern web development with JavaScript
Reasons to migrate to modern web development with JavaScriptReasons to migrate to modern web development with JavaScript
Reasons to migrate to modern web development with JavaScriptDavid Amend
 
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...Alan Pinstein
 
Gwt widget frameworks_presentation
Gwt widget frameworks_presentationGwt widget frameworks_presentation
Gwt widget frameworks_presentationDavid Amend
 
Continuous Delivery and Zero Downtime: What your architecture needs to succeed
Continuous Delivery and Zero Downtime: What your architecture needs to succeedContinuous Delivery and Zero Downtime: What your architecture needs to succeed
Continuous Delivery and Zero Downtime: What your architecture needs to succeedAxel Fontaine
 
Road to database automation: database source control
Road to database automation: database source controlRoad to database automation: database source control
Road to database automation: database source controlEduardo Piairo
 
Database version control without pain - the PHPNW10 version
Database version control without pain - the PHPNW10 versionDatabase version control without pain - the PHPNW10 version
Database version control without pain - the PHPNW10 versionHarrie Verveer
 
Database Source Control: Migrations vs State
Database Source Control: Migrations vs StateDatabase Source Control: Migrations vs State
Database Source Control: Migrations vs StateEduardo Piairo
 
Geecon 2014 - Five Ways to Not Suck at Being a Java Freelancer
Geecon 2014 - Five Ways to Not Suck at Being a Java FreelancerGeecon 2014 - Five Ways to Not Suck at Being a Java Freelancer
Geecon 2014 - Five Ways to Not Suck at Being a Java FreelancerRoberto Cortez
 
Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsMulti modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsDavid Amend
 
Flyway (33rd Degree)
Flyway (33rd Degree)Flyway (33rd Degree)
Flyway (33rd Degree)Axel Fontaine
 

Viewers also liked (20)

Just enough app server
Just enough app serverJust enough app server
Just enough app server
 
Development Horror Stories
Development Horror StoriesDevelopment Horror Stories
Development Horror Stories
 
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
 
Александр Захаров "Использование EntityGraph в JPA 2.1"
Александр Захаров "Использование EntityGraph в JPA 2.1"Александр Захаров "Использование EntityGraph в JPA 2.1"
Александр Захаров "Использование EntityGraph в JPA 2.1"
 
33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod
 
Gwt presentation
Gwt presentationGwt presentation
Gwt presentation
 
Javascript & Angular .js for the enterprise, lessons learned, typescript scal...
Javascript & Angular .js for the enterprise, lessons learned, typescript scal...Javascript & Angular .js for the enterprise, lessons learned, typescript scal...
Javascript & Angular .js for the enterprise, lessons learned, typescript scal...
 
Challenges and best practices of database continuous delivery
Challenges and best practices of database continuous deliveryChallenges and best practices of database continuous delivery
Challenges and best practices of database continuous delivery
 
The Challenges & Pitfalls of Database Continuous Delivery
The Challenges & Pitfalls of Database Continuous DeliveryThe Challenges & Pitfalls of Database Continuous Delivery
The Challenges & Pitfalls of Database Continuous Delivery
 
walkmod: how it works
walkmod: how it workswalkmod: how it works
walkmod: how it works
 
Reasons to migrate to modern web development with JavaScript
Reasons to migrate to modern web development with JavaScriptReasons to migrate to modern web development with JavaScript
Reasons to migrate to modern web development with JavaScript
 
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
 
Gwt widget frameworks_presentation
Gwt widget frameworks_presentationGwt widget frameworks_presentation
Gwt widget frameworks_presentation
 
Continuous Delivery and Zero Downtime: What your architecture needs to succeed
Continuous Delivery and Zero Downtime: What your architecture needs to succeedContinuous Delivery and Zero Downtime: What your architecture needs to succeed
Continuous Delivery and Zero Downtime: What your architecture needs to succeed
 
Road to database automation: database source control
Road to database automation: database source controlRoad to database automation: database source control
Road to database automation: database source control
 
Database version control without pain - the PHPNW10 version
Database version control without pain - the PHPNW10 versionDatabase version control without pain - the PHPNW10 version
Database version control without pain - the PHPNW10 version
 
Database Source Control: Migrations vs State
Database Source Control: Migrations vs StateDatabase Source Control: Migrations vs State
Database Source Control: Migrations vs State
 
Geecon 2014 - Five Ways to Not Suck at Being a Java Freelancer
Geecon 2014 - Five Ways to Not Suck at Being a Java FreelancerGeecon 2014 - Five Ways to Not Suck at Being a Java Freelancer
Geecon 2014 - Five Ways to Not Suck at Being a Java Freelancer
 
Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsMulti modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.js
 
Flyway (33rd Degree)
Flyway (33rd Degree)Flyway (33rd Degree)
Flyway (33rd Degree)
 

Similar to KYSUC - Keep Your Schema Under Control

8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development SecuritySam Bowne
 
CISSP Prep: Ch 9. Software Development Security
CISSP Prep: Ch 9. Software Development SecurityCISSP Prep: Ch 9. Software Development Security
CISSP Prep: Ch 9. Software Development SecuritySam Bowne
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development SecuritySam Bowne
 
DSD-INT 2020 Scripting a Delft-FEWS configuration - Verkade
DSD-INT 2020 Scripting a Delft-FEWS configuration - VerkadeDSD-INT 2020 Scripting a Delft-FEWS configuration - Verkade
DSD-INT 2020 Scripting a Delft-FEWS configuration - VerkadeDeltares
 
Bringing DevOps to the Database
Bringing DevOps to the DatabaseBringing DevOps to the Database
Bringing DevOps to the DatabaseMichaela Murray
 
Products.intro.forum version
Products.intro.forum versionProducts.intro.forum version
Products.intro.forum versionsqlserver.co.il
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIOliver Busse
 
APEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdfAPEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdfRichard Martens
 
Utilizing the open ntf domino api
Utilizing the open ntf domino apiUtilizing the open ntf domino api
Utilizing the open ntf domino apiOliver Busse
 
Learn from my Mistakes - Building Better Solutions in SPFx
Learn from my  Mistakes - Building Better Solutions in SPFxLearn from my  Mistakes - Building Better Solutions in SPFx
Learn from my Mistakes - Building Better Solutions in SPFxThomas Daly
 
Build automation best practices
Build automation best practicesBuild automation best practices
Build automation best practicesCode Mastery
 
Apex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEXApex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEXSergei Martens
 
KoprowskiT_Session2_SDNEvent_SourceControlForDBA
KoprowskiT_Session2_SDNEvent_SourceControlForDBAKoprowskiT_Session2_SDNEvent_SourceControlForDBA
KoprowskiT_Session2_SDNEvent_SourceControlForDBATobias Koprowski
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the BasicsUlrich Krause
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUlrich Krause
 
SSIS Monitoring Deep Dive
SSIS Monitoring Deep Dive�SSIS Monitoring Deep Dive�
SSIS Monitoring Deep DiveSolidQIT
 
SSIS Monitoring Deep Dive
SSIS Monitoring Deep DiveSSIS Monitoring Deep Dive
SSIS Monitoring Deep DiveDavide Mauri
 

Similar to KYSUC - Keep Your Schema Under Control (20)

8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
 
CISSP Prep: Ch 9. Software Development Security
CISSP Prep: Ch 9. Software Development SecurityCISSP Prep: Ch 9. Software Development Security
CISSP Prep: Ch 9. Software Development Security
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
 
DSD-INT 2020 Scripting a Delft-FEWS configuration - Verkade
DSD-INT 2020 Scripting a Delft-FEWS configuration - VerkadeDSD-INT 2020 Scripting a Delft-FEWS configuration - Verkade
DSD-INT 2020 Scripting a Delft-FEWS configuration - Verkade
 
Bringing DevOps to the Database
Bringing DevOps to the DatabaseBringing DevOps to the Database
Bringing DevOps to the Database
 
Products.intro.forum version
Products.intro.forum versionProducts.intro.forum version
Products.intro.forum version
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino API
 
APEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdfAPEX Application Lifecycle and Deployment 20220714.pdf
APEX Application Lifecycle and Deployment 20220714.pdf
 
DataOps with Project Amaterasu
DataOps with Project AmaterasuDataOps with Project Amaterasu
DataOps with Project Amaterasu
 
Utilizing the open ntf domino api
Utilizing the open ntf domino apiUtilizing the open ntf domino api
Utilizing the open ntf domino api
 
Learn from my Mistakes - Building Better Solutions in SPFx
Learn from my  Mistakes - Building Better Solutions in SPFxLearn from my  Mistakes - Building Better Solutions in SPFx
Learn from my Mistakes - Building Better Solutions in SPFx
 
Build automation best practices
Build automation best practicesBuild automation best practices
Build automation best practices
 
Apex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEXApex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEX
 
KoprowskiT_Session2_SDNEvent_SourceControlForDBA
KoprowskiT_Session2_SDNEvent_SourceControlForDBAKoprowskiT_Session2_SDNEvent_SourceControlForDBA
KoprowskiT_Session2_SDNEvent_SourceControlForDBA
 
Where to save my data, for devs!
Where to save my data, for devs!Where to save my data, for devs!
Where to save my data, for devs!
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the Basics
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
 
SSIS Monitoring Deep Dive
SSIS Monitoring Deep Dive�SSIS Monitoring Deep Dive�
SSIS Monitoring Deep Dive
 
SSIS Monitoring Deep Dive
SSIS Monitoring Deep DiveSSIS Monitoring Deep Dive
SSIS Monitoring Deep Dive
 
05 entity framework
05 entity framework05 entity framework
05 entity framework
 

Recently uploaded

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
 
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
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
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
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"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
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Recently uploaded (20)

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
 
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?
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
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
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"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...
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

KYSUC - Keep Your Schema Under Control

  • 1. KYSUC Keep Your Schema Under Control 04.FEV.2016 Nuno Alexandre Alves
  • 2. Speaker • Nuno Alves • Born at Coimbra / Lives in Leiria • Degree in Informatics Engineering (ESTG-IPLeiria) • Some experience with databases • Nowadays working in Critical Software, SA nuno.alexandre.alves@gmail.com nuno.alexandre.alves
  • 3. Disclaimer This presentation is: • From my personal experience • My own suggestions This presentation is NOT to: • Pointing fingers • Enumerate errors • This is better than that • Do not use this
  • 4. Just another day in “paradise” • How do you develop your scripts ? • Do you have a ER model of your Database(s) ? • Do you have your Database documented ? • How do you control your scripts versions ? • Do you have your test data under scripts ? • How do you test your scripts ? • How do you deploy your application and database to a specific version ?
  • 5. Agenda 1. Goals 2. Diagrams (ER models) 3. Scripts 4. Deploy 5. Documentation
  • 6. Goals for Today • Updated ER model • Scripts versioned • Easy Deploy • Easy Documentation • Schema Under Control !
  • 7. Agenda 1. Goals 2. Diagrams (ER models) 3. Scripts 4. Deploy 5. Documentation
  • 8. ER Model (1/4) Start New Project (from requirements) • Build your Conceptual Model • First Physical Model • First Scripts (version 1.0.0) • Print (paper not PDF) your Physical Model and put it in a Wall next to the team (old-school but it works) Assumptions: • High Level Architecture designed • RBDMS almost decided (for the first scripts)
  • 9. ER Model (2/4) Start New Project (already in PROD) / Maintenance • Ask for actual documentation (get lucky ) • DDL of actual production database • Import DDL in your development servers • Reverse Engineering • Build Conceptual Model (from Physical) if necessary • Script Physical Model with actual application version (ex: v3.5.2 – it’s your baseline)
  • 10. ER Model (3/4) Development / Maintenance • Keep your database changes updated in your ER Model • Use Reverse Engineering to do checkpoints (compare)
  • 11. ER Model (4/4) Tools • Use a Case Tool • PowerDesigner • Enterprise Architect • …
  • 12. Agenda 1. Goals 2. Diagrams (ER models) 3. Scripts 4. Deploy 5. Documentation
  • 13. Scripts (1/10) Scripts Development (projects reality) • Manually • I don’t have scripts. My ORM tool does it for me !?! • Database is something to store some data on it. I don’t care.
  • 14. Scripts (2/10) Scripts Development (projects reality) • WTF ?! • Your medical records relies on a database system • Your bank account relies on a database system • Your salary relies on a database system • … • Your life relies on too many database systems • Take your own conclusions
  • 15. Scripts (3/10) Then someday • How do I execute the database scripts ? Order By ? • Which development database is updated ? • How do you develop scripts ? • One script vs multiple scripts ? • Full Scripts vs Partial Scripts ? • It’s your ORM your Database developer ? • Naming Conventions for objects (where is the guide?) • I have a app log with this error “constraint SYS_098374 violated”. What is that constraint ? • The column CGTRTHY stores what ?
  • 16. Scripts (4/10) Database Scripts Under Control • Why ? • Is your source code under control ? • Does your source code have versions ? • Database scripts = source code ? • I think Yes ! • Table definition • Table initial data • Function / Stored Procedure / Package
  • 17. Scripts (5/10) Decide your Database Storage Strategy • Check production for rolling projects • Decide according to hosting supplier or client needs • Tablespaces • Data files • File groups My Suggestion (minimum) • One Tablespace for Data • One Tablespace for Indexes • One Tablespace for LOBs
  • 18. Scripts (6/10) Decide your Database / Schema(s) architecture • One schema, multiple users with diff grants • Multiple schemas, one/multiple users My Suggestion • Keep it simple • One schema/database, multiple users (grants/views) • FKs between multiple schemas not supported in all RDBMS • Distributed Transactions (do you really want ?!) • Multiple queries (joins in app server) • Are you creating your own RDBMS ?!
  • 19. Scripts (7/10) Decide your Database Naming Conventions • Easy identify a database object • Name every object in database • Don’t let default names under RDBMS
  • 20. Scripts (8/10) Script like source code • Use SQL formatting (for human readable) • Comment your SQL • Define objects language: PT; EN; FR … (don’t mix) Script for documentation • Comment every object (mandatory: wait and see) • Keep documentation in database dictionary • Useful for Reverse Engineering • Useful for Automatic Documentation • COMMENT ON TABLE • COMMENT ON COLUMN TABLE_NAME.COLUMN_NAME
  • 21. Scripts (9/10) Tools • Manually (Notepad, VI, … is your friend!) • Liquibase • mybatis • MIGRATEdb • migrate4j • Flyway • …
  • 23. Flyway (1/6) Overview • Scripts: SQL, Java • RDBMS Agnostic (JDBC driver) • Inside your source code • Placeholders (variables) • Multiple Execution Modes • Java API • Maven / Ant • Command line • Ex: V2_0_0_1_0001__script_name.sql
  • 24. Flyway (2/6) Decide your Script Naming Convention • V<JIRA_FIX_VERSION>_1_<4_digits>__<JIRA_KEY>.sql • <4_digitos> • Execution order
  • 25. Flyway (3/6) Put some code in your Script • Add an header to your SQL file • Add JIRA_KEY or JIRA URL as a comment • Commit
  • 26. Flyway (4/6) Decide your Execution Mode • Command line (java -jar …) • Maven/ANT • configure inside your IDE or in CLI • Use Maven profiles is necessary (useful in multiple databases/environments)
  • 27. Flyway (5/6) Flyway in action • flyway:info • Check schema version already installed • You need flyway:baseline for the first time
  • 28. Flyway (6/6) Flyway in action • flyway:migration • Script execution • With/without target release
  • 30. Agenda 1. Goals 2. Diagrams (ER models) 3. Scripts 4. Deploy 5. Documentation
  • 31. Deploy (1/7) Deploy Database Scripts • Do you test your scripts ? (how many times) • Do you re-create your schema from scratch ? • Do you have automatic deployment for your app ? • And your database ? • Do you have night builds ? • They include database too ? and automated tests ? • Do you simulate your client releases in development environments ? • Do you have confidence in your own scripts ?
  • 32. Deploy (2/7) Deploy Database (full / upgrade) • Use your Continuous Integration • Jenkins • Team City • Bamboo • Other …
  • 33. Deploy (3/7) Jenkins + Flyway = easy database deploy • Why Jenkins ? • Easy to configure • Parametrized builds • Many plugins (CVS, SVN, Maven, JIRA, Email, …) • Scheduler • Live Build Logs / Console output directly in browser • Why not ?!
  • 34. Deploy (4/7) Jenkins + Flyway = easy database deploy • Configure a Jenkins Job • Checkout script from VCS • Put some parameters • if necessary for customs build • for multiple versions • for multiple databases • Execute Flyway • via Maven • via custom Shell Script / Windows batch
  • 36. Deploy (5/7) Continuous Monitor your database • Oracle Enterprise Manager (Oracle) • pgwatch (PostgreSQL) • db2top (DB2) • SQL Server Management Studio (SQLServer) • MySQL Enterprise Monitor (MySQL) • … • Check administrator views (available in every RDBMS)
  • 37. Deploy (6/7) Continuous Monitor your database • Check some random SQL Statements • CPU • I/O • Get query plan for these statements • Help development team write better SQL • Create indexes according to business needs • Monitor sessions • Check Connection Pooling parameters • Min / Max Pool sizes (warn: multiple Connections Pools)
  • 38. Deploy (7/7) Help Development Team to help yourself • Write SQL Statements to log (debug mode) • Ask for log4jdbc / P6Spy / … (with parameters) • Write query times to log • Analyze top time consuming queries • Analyze top running queries • Ask for application times vs database times (in log) • Most of times the application consumes more time (yes it’s true) • Try to analyze how many queries are made for a business operation • Check the number of columns retrieved in every query (it’s really necessary 80 columns ?)
  • 39. Agenda 1. Goals 2. Diagrams (ER models) 3. Scripts 4. Deploy 5. Documentation
  • 40. Documentation (1/3) How do you produce your database documentation ? • Manually • I don’t have database documentation • “My client doesn’t need this documentation” • And your team ? • How do you maintain a project without documentation? • Most (~All) of your production tickets are resolved by SQL statements ! • Client business data is stored in “your” database (really?!)
  • 41. Documentation (2/3) Automatic Documentation • Use RDBMS data dictionary • information_schema.tables, … • user_tables, … • syscat.tables, … • Remember COMMENT ON … from scripts ? • “Export” to something useful • Word Document/PDF ? • Who reads a 800 pages document ?
  • 42. Documentation (3/3) Automatic Documentation • Perl script (reads data dictionary, outputs One HTML file) • Send to your client as a deliverable • Publish in your wiki • Open locally in your browser • Produce custom CSS: 30m - 1h • Update Documentation: 1 minute • Remember COMMENT ON 
  • 43. Summary (from initial goals) (1/2) ER Model • Use a Case Tool • Keep your model updated Scripts versioned • Use Flyway / Liquibase / Other • Script everything (data tests included) • Review your scripts • Naming Conventions • Comments
  • 44. Summary (from initial goals) (2/2) Easy Deploy • Use Jenkins / Team City / Bamboo / Other • Keep your database under Continuous Integration • Schedule your database builds • Parametrize your database deploy • Monitor your database close • Release Matrix isn’t nice to have (is mandatory) Easy Documentation • Comment your objects in data dictionary
  • 45. Main Goal Updated ER Model + Scripts versioned + Easy Deploy + Easy Documentation = KYSUC
  • 46. Extra Credits Define / ask for backup/restore plan • Test your backups (restore is your friend) • Check backup/restore times • Check database growth Compare data • Compare your production data with development data: reference data • Try to equal PKs IDs across environments (for referencial data)
  • 47. That’s It! Thank you for your time.