MySQL Schema Maintenance

8,998 views

Published on

Schema maintenance is a hot topic for database administrators. Especially if they have to maintain schemas for development, staging, and production, the task could be difficult and confusing. Using MySQL Workbench, schema maintenance is greatly simplified, and the tasks of synchronizing schemas across servers become easy and manageable.

Published in: Technology
1 Comment
9 Likes
Statistics
Notes
  • For data visualization,data analytics,data intelligence and ERP Tools, online training with job placements, register at http://www.todaycourses.com
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
8,998
On SlideShare
0
From Embeds
0
Number of Embeds
229
Actions
Shares
0
Downloads
161
Comments
1
Likes
9
Embeds 0
No embeds

No notes for slide

MySQL Schema Maintenance

  1. MySQL schema maintenance Giuseppe Maxia MySQL Community Team Lead This work is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License. Thursday, 03 December 2009
  2. about me - Giuseppe Maxia  a.k.a. The Data Charmer  MySQL Community Team Lead  Long time MySQL hacker  Formerly, database consultant, designer, coder.  A passion for QA  An even greater passion for open source  ... and community  Passionate blogger  http://datacharmer.blogspot.com Thursday, 03 December 2009
  3. Schema what? In a relational database, the schema defines the tables, the fields in each table, and the relationships between fields and tables. http://en.wikipedia.org/wiki/Schema_(database) Thursday, 03 December 2009
  4. tables Thursday, 03 December 2009
  5. tables table name column column column Thursday, 03 December 2009
  6. tables CREATE TABLE employees ( ID INT NOT NULL, name VARCHAR(20), name table salary INT, column column column PRIMARY KEY (ID) ) Thursday, 03 December 2009
  7. relationship departments employees ID INT ID INT name varchar (10) name varchar (10) salary INT dept_ID INT Thursday, 03 December 2009
  8. relationship departments employees ID INT ID INT name varchar (10) name varchar (10) salary INT 1 dept_ID INT Thursday, 03 December 2009
  9. relationship departments employees ID INT ID INT name varchar (10) name varchar (10) salary INT 1 dept_ID INT many Thursday, 03 December 2009
  10. relationship customer ID INT name varchar (10) sales cust_ID INT emp_ID INT s_date DATE amount DECIMAL employees ID INT name varchar (10) salary INT dept_ID INT Thursday, 03 December 2009
  11. relationship customer ID INT name varchar (10) sales cust_ID INT emp_ID INT s_date DATE amount DECIMAL employees ID INT name varchar (10) 1 salary INT dept_ID INT Thursday, 03 December 2009
  12. relationship customer many ID INT name varchar (10) sales cust_ID INT emp_ID INT s_date DATE amount DECIMAL employees ID INT name varchar (10) 1 salary INT dept_ID INT Thursday, 03 December 2009
  13. relationship customer many ID INT many to name varchar (10) many sales cust_ID INT emp_ID INT s_date DATE amount DECIMAL employees ID INT name varchar (10) 1 salary INT dept_ID INT Thursday, 03 December 2009
  14. Main actors • Production • Development • Stage • Test Thursday, 03 December 2009
  15. Production database • You must have one Thursday, 03 December 2009
  16. Development database • Where you create new things Thursday, 03 December 2009
  17. Test database • Where you experiment crazy ideas Thursday, 03 December 2009
  18. Stage database • Where you test before deploying to production Thursday, 03 December 2009
  19. Schema maintenance actions • Reverse engineering • Forward engineering • Synchronization Thursday, 03 December 2009
  20. Reverse Engineering Thursday, 03 December 2009
  21. Reverse Engineering DDL dept_emp department dept_manager employees titles salaries Thursday, 03 December 2009
  22. Reverse Engineering DDL dept_emp department dept_manager employees titles salaries Thursday, 03 December 2009
  23. Reverse Engineering DDL dept_emp department dept_manager employees titles salaries Thursday, 03 December 2009
  24. Forward Engineering Thursday, 03 December 2009
  25. Forward Engineering Thursday, 03 December 2009
  26. Forward Engineering Thursday, 03 December 2009
  27. Forward Engineering DDL dept_emp department dept_manager employees titles salaries Thursday, 03 December 2009
  28. Forward Engineering . ti ve ! truc G e s IN is d N g DDL A R n dept_emp W ee ri department g in dept_manager employees d en a r rw titles o salaries F Thursday, 03 December 2009
  29. Synchronization Thursday, 03 December 2009
  30. Synchronization Thursday, 03 December 2009
  31. Synchronization Thursday, 03 December 2009
  32. Synchronization Thursday, 03 December 2009
  33. Synchronization Thursday, 03 December 2009
  34. Synchronization Thursday, 03 December 2009
  35. Synchronization Thursday, 03 December 2009
  36. Synchronization Thursday, 03 December 2009
  37. Synchronization Thursday, 03 December 2009
  38. Synchronization Thursday, 03 December 2009
  39. Synchronization Thursday, 03 December 2009
  40. Synchronization Thursday, 03 December 2009
  41. Synchronization Thursday, 03 December 2009
  42. How it works yes Development OK? Production no no yes OK? Stage Test Thursday, 03 December 2009
  43. How else it works Development Production • Partition adjustment • Dynamic schemas Test Stage • Hot fixes Thursday, 03 December 2009
  44. What happens in between Development no OK? Test Thursday, 03 December 2009
  45. What happens in between Development no What now? OK? Test Thursday, 03 December 2009
  46. What happens in between Development no What now? Wrong schema here OK? Test Thursday, 03 December 2009
  47. What happens in between Development no What now? Wrong schema here OK? REWIND? Test Thursday, 03 December 2009
  48. Schema maintenance: how to 1. Poor man's way Thursday, 03 December 2009
  49. How poor is the poor man? • only command line access • No Perl, PHP, or Python • Can't install anything • Command line access • Perl or Python available • Can install modules • Command line access • GUI • Can install everything Thursday, 03 December 2009
  50. How poor is the poor man? ELY • only command line access EM R TR O EX PO • No Perl, PHP, or Python • Can't install anything • Command line access • Perl or Python available • Can install modules • Command line access • GUI • Can install everything Thursday, 03 December 2009
  51. How poor is the poor man? ELY • only command line access EM R TR O EX PO • No Perl, PHP, or Python • Can't install anything • Command line access OR • Perl or Python available PO • Can install modules • Command line access • GUI • Can install everything Thursday, 03 December 2009
  52. How poor is the poor man? ELY • only command line access EM R TR O EX PO • No Perl, PHP, or Python • Can't install anything • Command line access OR • Perl or Python available PO • Can install modules • Command line access RI CH • GUI • Can install everything Thursday, 03 December 2009
  53. so, the extremely poor man's way ... HOST 1 HOST 2 Development Production Thursday, 03 December 2009
  54. so, the extremely poor man's way ... HOST 1 HOST 2 get the Development Production schema TEXT FILE Thursday, 03 December 2009
  55. so, the extremely poor man's way ... HOST 1 HOST 2 get the Development Production get the schema schema TEXT TEXT FILE FILE Thursday, 03 December 2009
  56. so, the extremely poor man's way ... HOST 1 HOST 2 get the Development Production get the schema schema TEXT TEXT diff FILE FILE Thursday, 03 December 2009
  57. so, the extremely poor man's way ... HOST 1 HOST 2 get the Development Production get the schema schema TEXT TEXT diff FILE FILE then … uh … figure out how to continue Thursday, 03 December 2009
  58. the poor man's way ... HOST 1 HOST 2 Development Production get the get the schema schema TEXT diff TEXT FILE FILE Perl Script Thursday, 03 December 2009
  59. the poor man's way ... HOST 1 HOST 2 Development Production get the get the schema schema TEXT diff TEXT FILE FILE Perl Script TELLS YOU WHAT TO DO Thursday, 03 December 2009
  60. not so poor man's way ... HOST 1 HOST 2 Development Production DOES A LOT OF THINGS TELLS YOU WHAT TO DO Python Script http://schemasync.org Thursday, 03 December 2009
  61. not so poor man's way ... HOST 1 HOST 2 Development Production DOES A LOT OF THINGS TELLS YOU WHAT TO DO Python Script http://schemasync.org WARNING: doesn't deal with partitions Thursday, 03 December 2009
  62. The rich man http://aquafold.com Thursday, 03 December 2009
  63. The rich man http://aquafold.com WARNING: doesn't deal with partitions Thursday, 03 December 2009
  64. MySQL Workbench http://wb.mysql.com Thursday, 03 December 2009
  65. MySQL Workbench http://wb.mysql.com Thursday, 03 December 2009
  66. MySQL Workbench http://wb.mysql.com Thursday, 03 December 2009
  67. Schema and model Thursday, 03 December 2009
  68. Schema and model DDL dept_emp department dept_manager employees titles salaries Thursday, 03 December 2009
  69. Schema and model DDL dept_emp department dept_manager employees titles salaries Thursday, 03 December 2009
  70. Physical schema implemented in a specific DBMS Thursday, 03 December 2009
  71. Physical schema DDL dept_emp department dept_manager implemented employees in a specific DBMS titles salaries Thursday, 03 December 2009
  72. Conceptual model DBMS agnostic Thursday, 03 December 2009
  73. Conceptual model DBMS agnostic Thursday, 03 December 2009
  74. MySQL Workbench basics Thursday, 03 December 2009
  75. Creating tables (1) Thursday, 03 December 2009
  76. Creating tables (2) Thursday, 03 December 2009
  77. Creating tables (3) Thursday, 03 December 2009
  78. Creating tables (3) Thursday, 03 December 2009
  79. Creating tables (4) Thursday, 03 December 2009
  80. Creating tables (4) Thursday, 03 December 2009
  81. Creating tables (5) Thursday, 03 December 2009
  82. Creating tables (5) Thursday, 03 December 2009
  83. database connections(1) Thursday, 03 December 2009
  84. database connections(2) Thursday, 03 December 2009
  85. Reverse engineering in the old world Thursday, 03 December 2009
  86. Reverse engineering in the old world show create table departmentsG Create Table: CREATE TABLE `departments` ( `dept_id` int(10) unsigned NOT NULL, `department` char(30) NOT NULL, PRIMARY KEY (`dept_id`), KEY `department` (`department`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec) Thursday, 03 December 2009
  87. Reverse engineering in the old world show create table departmentsG Create Table: CREATE TABLE `departments` ( `dept_id` int(10) unsigned NOT NULL, `department` char(30) NOT NULL, PRIMARY KEY (`dept_id`), KEY `department` (`department`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec) Thursday, 03 December 2009
  88. Reverse engineering (1) Thursday, 03 December 2009
  89. Reverse engineering (2) Thursday, 03 December 2009
  90. Reverse engineering (3) Thursday, 03 December 2009
  91. Reverse engineering (4) Thursday, 03 December 2009
  92. Reverse engineering (5) Thursday, 03 December 2009
  93. Reverse engineering (6) Thursday, 03 December 2009
  94. Reverse engineering (7) Thursday, 03 December 2009
  95. Reverse engineering (8) Thursday, 03 December 2009
  96. Reverse engineering (9) Thursday, 03 December 2009
  97. Reverse engineering (10) Thursday, 03 December 2009
  98. forward engineering in the old world mysqldump --host=development -B --no-data crosstab > crosstab.sql mysql --host=stage < crosstab.sql Thursday, 03 December 2009
  99. Forward engineering (1) Thursday, 03 December 2009
  100. Forward engineering (2) Thursday, 03 December 2009
  101. Forward engineering (3) Thursday, 03 December 2009
  102. Forward engineering (4) Thursday, 03 December 2009
  103. synchronization in the old world Thursday, 03 December 2009
  104. Synchronization (1) Thursday, 03 December 2009
  105. Synchronization (1) Thursday, 03 December 2009
  106. Synchronization (2) Thursday, 03 December 2009
  107. Synchronization (3) Thursday, 03 December 2009
  108. Synchronization (4) Thursday, 03 December 2009
  109. Synchronization (5) Thursday, 03 December 2009
  110. Synchronization (6) Thursday, 03 December 2009
  111. More goodies • MySQL Workbench 5.2 (Beta) - live demo Thursday, 03 December 2009
  112. Thanks Let's talk! Thursday, 03 December 2009

×