SlideShare a Scribd company logo
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.
Ad

More Related Content

What's hot (20)

Migrating to Java 11
Migrating to Java 11Migrating to Java 11
Migrating to Java 11
Arto 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 Perl
Masaki 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 - TUT3287
Ahmad 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.0
ESUG
 
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
Arun Gupta
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
Jonas Brømsø
 
Saving Time By Testing With Jest
Saving Time By Testing With JestSaving Time By Testing With Jest
Saving Time By Testing With Jest
Ben McCormick
 
Social Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoSocial Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and Domino
Paul 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 objects
ITD Systems
 
Play Framework: The Basics
Play Framework: The BasicsPlay Framework: The Basics
Play Framework: The Basics
Philip 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.slides1
LiviaLiaoFontech
 
Immutable infrastructure:觀念與實作 (建議)
Immutable infrastructure:觀念與實作 (建議)Immutable infrastructure:觀念與實作 (建議)
Immutable infrastructure:觀念與實作 (建議)
William Yeh
 
History of Java 1/2
History of Java 1/2History of Java 1/2
History of Java 1/2
Eberhard Wolff
 
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
益裕 張
 
Migrating to Java 11
Migrating to Java 11Migrating to Java 11
Migrating to Java 11
Arto 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 Perl
Masaki 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 - TUT3287
Ahmad 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.0
ESUG
 
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
Arun Gupta
 
Saving Time By Testing With Jest
Saving Time By Testing With JestSaving Time By Testing With Jest
Saving Time By Testing With Jest
Ben McCormick
 
Social Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and DominoSocial Connections 2015 CrossWorlds and Domino
Social Connections 2015 CrossWorlds and Domino
Paul 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 objects
ITD Systems
 
Play Framework: The Basics
Play Framework: The BasicsPlay Framework: The Basics
Play Framework: The Basics
Philip 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.slides1
LiviaLiaoFontech
 
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
益裕 張
 

Viewers also liked (20)

Just enough app server
Just enough app serverJust enough app server
Just enough app server
Antonio Goncalves
 
Development Horror Stories
Development Horror StoriesDevelopment Horror Stories
Development Horror Stories
Roberto 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 7
Roberto 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 walkmod
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...
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 delivery
DBmaestro - 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 Delivery
Perforce
 
walkmod: how it works
walkmod: how it workswalkmod: how it works
walkmod: how it works
walkmod
 
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
David 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_presentation
David 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 succeed
Axel 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 control
Eduardo 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 version
Harrie Verveer
 
Database Source Control: Migrations vs State
Database Source Control: Migrations vs StateDatabase Source Control: Migrations vs State
Database Source Control: Migrations vs State
Eduardo 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 Freelancer
Roberto 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.js
David Amend
 
Flyway (33rd Degree)
Flyway (33rd Degree)Flyway (33rd Degree)
Flyway (33rd Degree)
Axel Fontaine
 
Development Horror Stories
Development Horror StoriesDevelopment Horror Stories
Development Horror Stories
Roberto 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 7
Roberto 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 walkmod
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...
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 delivery
DBmaestro - 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 Delivery
Perforce
 
walkmod: how it works
walkmod: how it workswalkmod: how it works
walkmod: how it works
walkmod
 
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
David 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_presentation
David 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 succeed
Axel 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 control
Eduardo 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 version
Harrie Verveer
 
Database Source Control: Migrations vs State
Database Source Control: Migrations vs StateDatabase Source Control: Migrations vs State
Database Source Control: Migrations vs State
Eduardo 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 Freelancer
Roberto 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.js
David Amend
 
Flyway (33rd Degree)
Flyway (33rd Degree)Flyway (33rd Degree)
Flyway (33rd Degree)
Axel Fontaine
 
Ad

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

8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
Sam 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 Security
Sam Bowne
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
Sam 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 - Verkade
Deltares
 
Bringing DevOps to the Database
Bringing DevOps to the DatabaseBringing DevOps to the Database
Bringing DevOps to the Database
Michaela Murray
 
Products.intro.forum version
Products.intro.forum versionProducts.intro.forum version
Products.intro.forum version
sqlserver.co.il
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino API
Oliver 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.pdf
Richard Martens
 
DataOps with Project Amaterasu
DataOps with Project AmaterasuDataOps with Project Amaterasu
DataOps with Project Amaterasu
DataWorks Summit/Hadoop Summit
 
Utilizing the open ntf domino api
Utilizing the open ntf domino apiUtilizing the open ntf domino api
Utilizing the open ntf domino api
Oliver 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 SPFx
Thomas Daly
 
Build automation best practices
Build automation best practicesBuild automation best practices
Build automation best practices
Code Mastery
 
Apex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEXApex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEX
Sergei Martens
 
KoprowskiT_Session2_SDNEvent_SourceControlForDBA
KoprowskiT_Session2_SDNEvent_SourceControlForDBAKoprowskiT_Session2_SDNEvent_SourceControlForDBA
KoprowskiT_Session2_SDNEvent_SourceControlForDBA
Tobias Koprowski
 
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!
SharePoint Saturday New Jersey
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the Basics
Ulrich Krause
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
Ulrich Krause
 
SSIS Monitoring Deep Dive
SSIS Monitoring Deep Dive�SSIS Monitoring Deep Dive�
SSIS Monitoring Deep Dive
SolidQIT
 
SSIS Monitoring Deep Dive
SSIS Monitoring Deep DiveSSIS Monitoring Deep Dive
SSIS Monitoring Deep Dive
Davide Mauri
 
05 entity framework
05 entity framework05 entity framework
05 entity framework
Bat Programmer
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
Sam 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 Security
Sam Bowne
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
Sam 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 - Verkade
Deltares
 
Bringing DevOps to the Database
Bringing DevOps to the DatabaseBringing DevOps to the Database
Bringing DevOps to the Database
Michaela Murray
 
Products.intro.forum version
Products.intro.forum versionProducts.intro.forum version
Products.intro.forum version
sqlserver.co.il
 
Utilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino APIUtilizing the OpenNTF Domino API
Utilizing the OpenNTF Domino API
Oliver 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.pdf
Richard Martens
 
Utilizing the open ntf domino api
Utilizing the open ntf domino apiUtilizing the open ntf domino api
Utilizing the open ntf domino api
Oliver 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 SPFx
Thomas Daly
 
Build automation best practices
Build automation best practicesBuild automation best practices
Build automation best practices
Code Mastery
 
Apex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEXApex world 2018 continuously delivering APEX
Apex world 2018 continuously delivering APEX
Sergei Martens
 
KoprowskiT_Session2_SDNEvent_SourceControlForDBA
KoprowskiT_Session2_SDNEvent_SourceControlForDBAKoprowskiT_Session2_SDNEvent_SourceControlForDBA
KoprowskiT_Session2_SDNEvent_SourceControlForDBA
Tobias Koprowski
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the Basics
Ulrich Krause
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
Ulrich Krause
 
SSIS Monitoring Deep Dive
SSIS Monitoring Deep Dive�SSIS Monitoring Deep Dive�
SSIS Monitoring Deep Dive
SolidQIT
 
SSIS Monitoring Deep Dive
SSIS Monitoring Deep DiveSSIS Monitoring Deep Dive
SSIS Monitoring Deep Dive
Davide Mauri
 
Ad

Recently uploaded (20)

UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 

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 [email protected] 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.