php tek 2006 in Orlando Florida Lukas Kahwe Smith smith@pooteeweet.org



Similar documents
Database Schema Deployment. Lukas Smith - lukas@liip.ch CodeWorks PHP on the ROAD

database abstraction layer database abstraction layers in PHP Lukas Smith BackendMedia

Toad Data Modeler - Features Matrix

SQL Databases Course. by Applied Technology Research Center. This course provides training for MySQL, Oracle, SQL Server and PostgreSQL databases.

Instant SQL Programming

Database as a Service (DaaS) Version 1.02

Oracle 10g PL/SQL Training

Oracle SQL. Course Summary. Duration. Objectives

Database migration. from Sybase ASE to PostgreSQL. Achim Eisele and Jens Wilke. 1&1 Internet AG

SQL Injection. The ability to inject SQL commands into the database engine through an existing application

SQL Server Training Course Content

How to Improve Database Connectivity With the Data Tools Platform. John Graham (Sybase Data Tooling) Brian Payton (IBM Information Management)

Linas Virbalas Continuent, Inc.

Introduction to Triggers using SQL

Oracle Database Development Standards For DNR Staff and Contractors. Table of Contents

Databases What the Specification Says

Oracle Database: SQL and PL/SQL Fundamentals NEW

How To Create A Table In Sql (Ahem)

Netezza Workbench Documentation

Oracle Database 10g Express

Oracle Database: SQL and PL/SQL Fundamentals

Oracle Database 12c: Introduction to SQL Ed 1.1


SQL SERVER DEVELOPER Available Features and Tools New Capabilities SQL Services Product Licensing Product Editions Will teach in class room

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

MySQL Administration and Management Essentials

OBJECTS AND DATABASES. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 21

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

Oracle Database 10g: Introduction to SQL

Oracle Database 11g SQL

Database Systems. S. Adams. Dilbert. Available: Hans-Petter Halvorsen, M.Sc.

Short notes on webpage programming languages

Oracle Database: Introduction to SQL

PAINLESS MULTI-DBMS STRATEGY For Magic Developers

Microsoft SQL Server Beginner course content (3-day)

Auditing Data Access Without Bringing Your Database To Its Knees

ATTACHMENT 6 SQL Server 2012 Programming Standards

Oracle Database: SQL and PL/SQL Fundamentals

NEMUG Feb Create Your Own Web Data Mart with MySQL

Application Development With Data Studio

Oracle Database: Introduction to SQL

PeopleSoft DDL & DDL Management

Using MySQL for Big Data Advantage Integrate for Insight Sastry Vedantam

D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to:

$99.95 per user. SQL Server 2005 Database Administration CourseId: 152 Skill level: Run Time: 30+ hours (158 videos)

DBMS / Business Intelligence, SQL Server

Chapter 9 Java and SQL. Wang Yang wyang@njnet.edu.cn

Oracle Warehouse Builder 10g

Conventional Files versus the Database. Files versus Database. Pros and Cons of Conventional Files. Pros and Cons of Databases. Fields (continued)

Oracle. Brief Course Content This course can be done in modular form as per the detail below. ORA-1 Oracle Database 10g: SQL 4 Weeks 4000/-

Demystified CONTENTS Acknowledgments xvii Introduction xix CHAPTER 1 Database Fundamentals CHAPTER 2 Exploring Relational Database Components

PG DAC. Syllabus. Content. Eligibility Criteria

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

Commercial Database Software Development- A review.

Consolidate by Migrating Your Databases to Oracle Database 11g. Fred Louis Enterprise Architect

MySQL for Beginners Ed 3

ORACLE DATABASE 11G: COMPLETE

Oracle Database: Introduction to SQL

Relational Databases for the Business Analyst

Managing Third Party Databases and Building Your Data Warehouse

Driver for JDBC Implementation Guide

Structured Query Language. Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics

Oracle Database: SQL and PL/SQL Fundamentals NEW

Embarcadero DB Change Manager 6.0 and DB Change Manager XE2

LearnFromGuru Polish your knowledge

Introduction to Databases

SQL, PL/SQL FALL Semester 2013

What's New with SQL Developer Data Modeler. Heli Helskyaho HrOUG 2015

Comparing SQL and NOSQL databases

Information Systems SQL. Nikolaj Popov

SQL Server Administrator Introduction - 3 Days Objectives

Developing Microsoft SQL Server Databases 20464C; 5 Days

Database Migration from MySQL to RDM Server

Oracle to MySQL Migration

Basic Unix/Linux 1. Software Testing Interview Prep

DATABASE REVERSE ENGINEERING

Tracking Database Schema Changes. Guidelines on database versioning using Devart tools

DB2 - DATABASE SECURITY

Introduction to Database. Systems HANS- PETTER HALVORSEN,

Data Discovery & Documentation PROCEDURE

SQL Server for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

<Insert Picture Here> Introducing Data Modeling and Design with Oracle SQL Developer Data Modeler

David Dye. Extract, Transform, Load

Oracle(PL/SQL) Training

Discovering SQL. Wiley Publishing, Inc. A HANDS-ON GUIDE FOR BEGINNERS. Alex Kriegel WILEY

Extracting META information from Interbase/Firebird SQL (INFORMATION_SCHEMA)

Introduction to MRP-Link

Database Extension 1.5 ez Publish Extension Manual

20464C: Developing Microsoft SQL Server Databases

OLTP Meets Bigdata, Challenges, Options, and Future Saibabu Devabhaktuni

Real-Time Database Protection and. Overview IBM Corporation

Scheme G. Sample Test Paper-I

SQL. Short introduction

Database Programming with PL/SQL: Learning Objectives

PeopleTools Tables: The Application Repository in the Database

How to Implement Multi-way Active/Active Replication SIMPLY

INTRODUCTION TO DATABASE SYSTEMS

Transcription:

Database Schema Deployment php tek 2006 in Orlando Florida Lukas Kahwe Smith smith@pooteeweet.org

Agenda: The Challenge Diff Tools ER Tools Synchronisation Tools Logging Changes XML Formats SCM Tools Install Scripting Update Scripting Alternative Approaches

Terminology: DDL Data Definition Language DML CREATE ALTER DROP Data Manipulation Language INSERT UPDATE DELETE

The Challenge: Overview Getting the DDL and DML SQL diff tools can generate DDL Usually RDBMS specific Data synchronisation very tricky Especially if DDL and DML needs to be mixed Deal with object dependencies Foreign Keys, Views, Stored Routines Column order matters with sloppy code No additional steps during development Less steps during packaging Allow releases to be skipped

The Challenge: Example Version 1.0.0 User database with a single phone number Version 1.1.0 Allow infinate phone numbers per user by adding a phone numbers table Add new table phone numbers CREATE TABLE phone_nums (user_id INT REFERENCES user, phone_num CHAR(20)) Move all data into the new table INSERT INTO phone_nums SELECT user_id, phone_num FROM users Drop the old phone numbers column ALTER TABLE users DROP COLUMN phone_num

Diff Tools: Overview Generate DDL by comparing SQL files Installed schema Does not handle DML Tend to be RDBMS specific Examples SQLYog (Win, MySQL, $) Toad (XXX, different RDBMS, $$) AdeptSQL (Win, MS SQL, $$) Most modeling tools

Diff Tools: Example Playing with SQLYog

ER Tools: Overview ER Modeling tools Visually design schema Synchronize model Reverse engineer model Examples DBDesigner (Win, Generic) MySQL Workbench (Win/*nix, MySQL) PowerDesigner (XXX, Generic, $$$) ERWin (XXX, Generic, $$$) Visio (Win, Generic, $$)

ER Tools: Example Playing with DBDesigner

Synchronisation Tools: Find differences in data One way synchronisation is easy Two way synchronisation is tricky Only useable in the rare case where all clients have the same data No way to generate DML to make the same changes on different data

Logging Changes: PostGreSQL: log_statement mod MYSQL: binarylog with mysqlbinlog util Oracle: AUDIT command DB2: db2audit command Alternative approach Cronjob that checks for changes in the information schema Only handles DDL Write all DDL and DML to a log and only execute changes from the log

XML Formats: AXMLS RDBMS independent XML format Bundled with ADODB Supports Tables Columns Autoincrement Constraints (not fully abstracted) Indexes Initialization Queries (not abstracted) Create, alter, remove schema Execute directly or dump statements

XML Formats: Metabase XML Mostly same feature set as AXMLS Adds support for sequences and variables XML format uses no attributes No support for plain queries No support to remove schemas Only support for primary/unique constraints Implemented in Metabase PEAR::MDB2_Schema ezc/databaseschema DBDesigner exports to Metabase XML

XML Formats: Example Playing with PEAR::MDB2_Schema and WebBuilder2 Application framework

SCM Tools: Standard SCM work line based Needs SQL parser in order to work statement based Few SQL aware solutions available Daversy (Win, SQLite/Oracle) Keep one database object per file Watch out for dependencies VIEWs Stored Routines Triggers and Foreign Keys

Install Scripting: Getting Started Dump test master for every release Advantage More or less automated Disadvantage No handling for DML Initial dump + all DDL and DML Check current schema before applying Can be applied to any version Advantage A singe script for install and upgrades Disadvantage Gets increasingly long

Install Scripting: Dependency Hell Native dump tools handle dependencies Create dependency graph Figure out dependencies Order statements accordingly Use dummies Create dummy implementations of all referenceing database objects VIEWs Stored Routines Replace dummies with actual implementation

Update Scripting: Get DDL and DML Log every DDL and DML Diff between current and last release Compare diff against DDL and DML log LOG CREATE TABLE phone_nums (user_id INT REFERENCES users, phone_num INT) ALTER TABLE phone_nums MODIFY phone_num CHAR(20) (2) INSERT INTO phone_nums SELECT user_id, phone_num FROM users (3) ALTER TABLE users DROP COLUMN phone_num DIFF ALTER TABLE users DROP COLUMN phone_num (1) CREATE TABLE phone_nums (user_id INT REFERENCES users, phone_num CHAR(20))

Update Scripting: Organize DDL and DML Ordered list of DDL and DML changes Dependency order follows from log Every change has unique name per release code to detect if the change is required potentially a rollback script Ordered list of data unrelated objects Views and summary tables Stored routines

Update Scripting: Code Flow Determine version and integrity of current installed database Load all necessary changes Enclose in transaction not supported in MySQL Load previous changes if necessary Hard code deviations from previous releases by referencing the unique change name Skip buggy irrelevant/changes Fold multiple changes into single change Reload data unrelated objects Update table stats

Update Scripting: Notes Always explicitly hard code columns INSERT INTO foo VALUES (..); SELECT *.. Grants are a major PITA Store grants with object definitions Old RDBMS versions might not support New DDL: emulate with copy, drop, create New optional features MySQL only syntax: /*!50100 PARTITION.. */ backwards compatibility Optionally show list of statements before execution for additional security

Alternative Approaches: Some more ideas Plan ahead to minimize changes ;-) Keep old schema unchanged Create a new schema for all new features Use VIEWs to handle changes to existing tables And/or copy old data to new schema as needed Disadvantages Schema becomes messy Performance overhead

References: These slides http://pooteeweet.org/files/phptek06/database_schema_dep loyment.pdf SQLYog http://www.webyog.com/ Toad http://www.oracle.com/technology/products/designer DBDesigner http://fabforce.net/dbdesigner4/ MySQL Workbench http://forums.mysql.com/list.php?113 AdeptSQL http://www.adeptsql.com/

References: More.. Sybase Powerdesigner http://www.sybase.com/products/developmentintegration/po werdesigner ERWin http://www3.ca.com/solutions/product.asp?id=260 Visio http://office.microsoft.com/visio/ Daversy http://www.svn-hosting.com/trac/daversy http://www.svnhosting.com/trac/daversy/wiki/dependencies

References: Still more PostGreSQL logging http://www.postgresql.org/docs/8.1/interactive/runtimeconfig-logging.html MySQL logging http://dev.mysql.com/doc/refman/5.0/en/binary-log.html Oracle logging http://www.securityfocus.com/infocus/1689 DB2 logging http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.js p?topic=/com.ibm.db2.udb.doc/core/r0002051.htm

References: Yet More.. ADODB xml-schema http://adodb-xmlschema.sourceforge.net/docs/index.html ezc/databaseschema http://ez.no/doc/components/view/latest/(file)/classtrees_d atabaseschema.html PEAR::MDB2_Schema http://pear.php.net/package/mdb2_schema/ WebBuilder2 Schema Manager http://svn.oss.backendmedia.com/modules/schema_manage r/schema_manager.phps SCM for databases? http://blogs.ittoolbox.com/database/soup/archives/007666.a sp

Thank you for listening.. Comments? Questions? smith@pooteeweet.org