SlideShare a Scribd company logo
1 of 20
Download to read offline
Schemadoc
  Bill Karwin, Percona Inc.
Schema Can Be Unclear
CREATE TABLE AccountActivity (
    Id        INT PRIMARY KEY,
                                           whose name?
    Name      VARCHAR(100),
    Status    VARCHAR(20),           what are the values?

    EntityNum INT,                 what’s an entity?
    Order     INT                  what’s a number?
 );                          commerce, or ordinal?




                                          www.percona.com
Comments
CREATE TABLE AccountActivity (
   Id        INT PRIMARY KEY,
   Name      VARCHAR(100) COMMENT ‘person who placed the order’,
   Status    VARCHAR(20) COMMENT ‘new, open, or closed’,
   EntityNum INT            COMMENT ‘how many items in the order’,
   Order     INT            COMMENT ‘reference to the Orders table’
) COMMENT ‘any change to e-commerce orders’;




                                                    www.percona.com
Length
• Limits increased in MySQL 5.5.3:
  • Per column: 1024 characters
  • Per index: 1024 characters
  • Per table: 2048 characters
  • Per partition: 80 characters
     (MySQL 5.6 increases this to 1024)




                                          www.percona.com
Why don’t we use comments?
SELECT TABLE_NAME, TABLE_COMMENT
FROM INFORMATION_SCHEMA.TABLES
WHERE (TABLE_SCHEMA, TABLE_NAME) = (‘EcommerceDB’, ‘AccountActivity’);
SELECT COLUMN_NAME, COLUMN_COMMENT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE (TABLE_SCHEMA, TABLE_NAME) = (‘EcommerceDB’, ‘AccountActivity’)
ORDER BY ORDINAL_POSITION;
SELECT INDEX_NAME, CONCAT(‘(’, GROUP_CONCAT(COLUMN_NAME ORDER
BY SEQ_IN_INDEX), ‘)’) AS INDEX_COLUMNS, COMMENT AS INDEX_COMMENT
FROM INFORMATION_SCHEMA.STATISTICS
WHERE (TABLE_SCHEMA, TABLE_NAME) = (‘EcommerceDB’, ‘AccountActivity’)
GROUP BY INDEX_NAME;
SELECT PARTITION_NAME, PARTITION_COMMENT
FROM INFORMATION_SCHEMA.PARTITIONS
WHERE (TABLE_SCHEMA, TABLE_NAME) = (‘EcommerceDB’, ‘AccountActivity’)
ORDER BY PARTITION_ORDINAL_POSITION;



                                                         www.percona.com
“Is there a tool for MySQL
 like javadoc for Java code?”




                         www.percona.com
development
              dba

   documentation



                    www.percona.com
schemadoc


            www.percona.com
Usage
$ schemadoc -v h=dbserver,D=EcommerceDB,u=root,p=xxxx
Loading metadata...
Running online analysis...
done.
Outputting to html.
Rendering pages for tables. done.
Rendering pages for views done.
Rendering pages for procedures done.
Rendering pages for triggers done.
Rendering page for schema summary... done.
Rendering page for schema link... done.
Rendering page for deprecated-list... done.
Rendering page for all-index... done.
Rendering page for help-doc... done.
Rendering page for allschema-frame... done.
Rendering page for index... done.


                                              www.percona.com
hooray.




          www.percona.com
But Wait, There’s More
• Parses SQL dump file
• Reads from a live MySQL instance
• Document many schemas
• Update one schema at a time




                                     www.percona.com
Schema Analysis
• Number of indexes and columns per data type
• Columns with same name but different type
• ENUM columns that aren’t NOT NULL
• Use of FLOAT or DOUBLE
• Tables with one index per column
• Tables with one index over all columns
• Tables with no indexes
• INT(N) other than default N
• Lack of INT UNSIGNED columns
                                      www.percona.com
Schema Analysis
• Tables that look like Entity-Attribute-Value
• Tables that look like Polymorphic Associations
• Superfluous primary key
• Report table with least / most indexes
• IP addresses stored in VARCHAR
• Excessive use of VARCHAR(255),
   report actual max string length
...And supports plugins for other checks!


                                            www.percona.com
yes, we get it.




                  www.percona.com
Future of Schemadoc
• Integrate with Percona Toolkit library
• Read extra metadata (foreign keys)
• Show table sizes and growth rates
• Show SQL privileges (who has access?)
• CLI for adding / updating comments
• Batch-mode output

• Redesign HTML output with modern look & feel...

                                       www.percona.com
Future of Schemadoc




                  www.percona.com
launchpad.net/
  schemadoc

             www.percona.com
Copyright 2012 Bill Karwin
           www.slideshare.net/billkarwin

          Released under a Creative Commons 3.0 License:
           http://creativecommons.org/licenses/by-nc-nd/3.0/
              You are free to share - to copy, distribute and
             transmit this work, under the following conditions:




   Attribution.               Noncommercial.          No Derivative Works.
You must attribute this   You may not use this work       You may not alter,
 work to Bill Karwin.      for commercial purposes.      transform, or build
                                                           upon this work.

                                                               www.percona.com

More Related Content

What's hot

TSQL Coding Guidelines
TSQL Coding GuidelinesTSQL Coding Guidelines
TSQL Coding GuidelinesChris Adkin
 
Mysql query optimization
Mysql query optimizationMysql query optimization
Mysql query optimizationBaohua Cai
 
MySQL Index Cookbook
MySQL Index CookbookMySQL Index Cookbook
MySQL Index CookbookMYXPLAIN
 
An introduction to SQLAlchemy
An introduction to SQLAlchemyAn introduction to SQLAlchemy
An introduction to SQLAlchemymengukagan
 
Explaining the MySQL Explain
Explaining the MySQL ExplainExplaining the MySQL Explain
Explaining the MySQL ExplainMYXPLAIN
 
Oracle basic queries
Oracle basic queriesOracle basic queries
Oracle basic queriesPRAKHAR JHA
 
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
MySQL Indexing : Improving Query Performance Using Index (Covering Index)MySQL Indexing : Improving Query Performance Using Index (Covering Index)
MySQL Indexing : Improving Query Performance Using Index (Covering Index)Hemant Kumar Singh
 
Entity Attribute Value (Eav)
Entity   Attribute   Value (Eav)Entity   Attribute   Value (Eav)
Entity Attribute Value (Eav)Tâm
 
56 Query Optimization
56 Query Optimization56 Query Optimization
56 Query OptimizationMYXPLAIN
 
Optimizing queries MySQL
Optimizing queries MySQLOptimizing queries MySQL
Optimizing queries MySQLGeorgi Sotirov
 
Chetan postgresql partitioning
Chetan postgresql partitioningChetan postgresql partitioning
Chetan postgresql partitioningsuniltomar04
 
How to Design Indexes, Really
How to Design Indexes, ReallyHow to Design Indexes, Really
How to Design Indexes, ReallyMYXPLAIN
 
Testing Cassandra Guarantees under Diverse Failure Modes with Jepsen
Testing Cassandra Guarantees under Diverse Failure Modes with JepsenTesting Cassandra Guarantees under Diverse Failure Modes with Jepsen
Testing Cassandra Guarantees under Diverse Failure Modes with Jepsenjkni
 
PyCon 2010 SQLAlchemy tutorial
PyCon 2010 SQLAlchemy tutorialPyCon 2010 SQLAlchemy tutorial
PyCon 2010 SQLAlchemy tutorialjbellis
 
Database development coding standards
Database development coding standardsDatabase development coding standards
Database development coding standardsAlessandro Baratella
 
Database presentation
Database presentationDatabase presentation
Database presentationwebhostingguy
 
Avoiding cursors with sql server 2005 tech republic
Avoiding cursors with sql server 2005   tech republicAvoiding cursors with sql server 2005   tech republic
Avoiding cursors with sql server 2005 tech republicKaing Menglieng
 
Getting Creative with WordPress Queries, Again
Getting Creative with WordPress Queries, AgainGetting Creative with WordPress Queries, Again
Getting Creative with WordPress Queries, AgainDrewAPicture
 
Playing With (B)Sqli
Playing With (B)SqliPlaying With (B)Sqli
Playing With (B)SqliChema Alonso
 

What's hot (20)

TSQL Coding Guidelines
TSQL Coding GuidelinesTSQL Coding Guidelines
TSQL Coding Guidelines
 
Sql Injection Myths and Fallacies
Sql Injection Myths and FallaciesSql Injection Myths and Fallacies
Sql Injection Myths and Fallacies
 
Mysql query optimization
Mysql query optimizationMysql query optimization
Mysql query optimization
 
MySQL Index Cookbook
MySQL Index CookbookMySQL Index Cookbook
MySQL Index Cookbook
 
An introduction to SQLAlchemy
An introduction to SQLAlchemyAn introduction to SQLAlchemy
An introduction to SQLAlchemy
 
Explaining the MySQL Explain
Explaining the MySQL ExplainExplaining the MySQL Explain
Explaining the MySQL Explain
 
Oracle basic queries
Oracle basic queriesOracle basic queries
Oracle basic queries
 
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
MySQL Indexing : Improving Query Performance Using Index (Covering Index)MySQL Indexing : Improving Query Performance Using Index (Covering Index)
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
 
Entity Attribute Value (Eav)
Entity   Attribute   Value (Eav)Entity   Attribute   Value (Eav)
Entity Attribute Value (Eav)
 
56 Query Optimization
56 Query Optimization56 Query Optimization
56 Query Optimization
 
Optimizing queries MySQL
Optimizing queries MySQLOptimizing queries MySQL
Optimizing queries MySQL
 
Chetan postgresql partitioning
Chetan postgresql partitioningChetan postgresql partitioning
Chetan postgresql partitioning
 
How to Design Indexes, Really
How to Design Indexes, ReallyHow to Design Indexes, Really
How to Design Indexes, Really
 
Testing Cassandra Guarantees under Diverse Failure Modes with Jepsen
Testing Cassandra Guarantees under Diverse Failure Modes with JepsenTesting Cassandra Guarantees under Diverse Failure Modes with Jepsen
Testing Cassandra Guarantees under Diverse Failure Modes with Jepsen
 
PyCon 2010 SQLAlchemy tutorial
PyCon 2010 SQLAlchemy tutorialPyCon 2010 SQLAlchemy tutorial
PyCon 2010 SQLAlchemy tutorial
 
Database development coding standards
Database development coding standardsDatabase development coding standards
Database development coding standards
 
Database presentation
Database presentationDatabase presentation
Database presentation
 
Avoiding cursors with sql server 2005 tech republic
Avoiding cursors with sql server 2005   tech republicAvoiding cursors with sql server 2005   tech republic
Avoiding cursors with sql server 2005 tech republic
 
Getting Creative with WordPress Queries, Again
Getting Creative with WordPress Queries, AgainGetting Creative with WordPress Queries, Again
Getting Creative with WordPress Queries, Again
 
Playing With (B)Sqli
Playing With (B)SqliPlaying With (B)Sqli
Playing With (B)Sqli
 

Viewers also liked (15)

MySQL 5.5 Guide to InnoDB Status
MySQL 5.5 Guide to InnoDB StatusMySQL 5.5 Guide to InnoDB Status
MySQL 5.5 Guide to InnoDB Status
 
How to Design Indexes, Really
How to Design Indexes, ReallyHow to Design Indexes, Really
How to Design Indexes, Really
 
Percona toolkit
Percona toolkitPercona toolkit
Percona toolkit
 
InnoDB Locking Explained with Stick Figures
InnoDB Locking Explained with Stick FiguresInnoDB Locking Explained with Stick Figures
InnoDB Locking Explained with Stick Figures
 
Survey of Percona Toolkit
Survey of Percona ToolkitSurvey of Percona Toolkit
Survey of Percona Toolkit
 
Requirements the Last Bottleneck
Requirements the Last BottleneckRequirements the Last Bottleneck
Requirements the Last Bottleneck
 
SQL Outer Joins for Fun and Profit
SQL Outer Joins for Fun and ProfitSQL Outer Joins for Fun and Profit
SQL Outer Joins for Fun and Profit
 
Models for hierarchical data
Models for hierarchical dataModels for hierarchical data
Models for hierarchical data
 
Sql Antipatterns Strike Back
Sql Antipatterns Strike BackSql Antipatterns Strike Back
Sql Antipatterns Strike Back
 
Full Text Search In PostgreSQL
Full Text Search In PostgreSQLFull Text Search In PostgreSQL
Full Text Search In PostgreSQL
 
Hierarchical data models in Relational Databases
Hierarchical data models in Relational DatabasesHierarchical data models in Relational Databases
Hierarchical data models in Relational Databases
 
Optimizing MySQL
Optimizing MySQLOptimizing MySQL
Optimizing MySQL
 
Trees and Hierarchies in SQL
Trees and Hierarchies in SQLTrees and Hierarchies in SQL
Trees and Hierarchies in SQL
 
InnoDB Internal
InnoDB InternalInnoDB Internal
InnoDB Internal
 
Trees In The Database - Advanced data structures
Trees In The Database - Advanced data structuresTrees In The Database - Advanced data structures
Trees In The Database - Advanced data structures
 

Similar to Schemadoc

Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsSalesforce Developers
 
Kaseya Connect 2012 - KASEYA CUSTOM REPORT CREATION
Kaseya Connect 2012 - KASEYA CUSTOM REPORT CREATIONKaseya Connect 2012 - KASEYA CUSTOM REPORT CREATION
Kaseya Connect 2012 - KASEYA CUSTOM REPORT CREATIONKaseya
 
Model-Driven Software Development - Strategies for Design & Implementation of...
Model-Driven Software Development - Strategies for Design & Implementation of...Model-Driven Software Development - Strategies for Design & Implementation of...
Model-Driven Software Development - Strategies for Design & Implementation of...Eelco Visser
 
Strategies for Design & Implementation of Domain-Specific Languages
Strategies for Design & Implementation of Domain-Specific LanguagesStrategies for Design & Implementation of Domain-Specific Languages
Strategies for Design & Implementation of Domain-Specific LanguagesEelco Visser
 
Geek Sync | Rewriting Bad SQL Code 101
Geek Sync | Rewriting Bad SQL Code 101Geek Sync | Rewriting Bad SQL Code 101
Geek Sync | Rewriting Bad SQL Code 101IDERA Software
 
Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB graphdevroom
 
Cassandra Tutorial
Cassandra TutorialCassandra Tutorial
Cassandra Tutorialmubarakss
 
BITM3730Week14.pptx
BITM3730Week14.pptxBITM3730Week14.pptx
BITM3730Week14.pptxMattMarino13
 
Introduction to PostgreSQL
Introduction to PostgreSQLIntroduction to PostgreSQL
Introduction to PostgreSQLJoel Brewer
 
A "M"ind Bending Experience. Power Query for Power BI and Beyond.
A "M"ind Bending Experience. Power Query for Power BI and Beyond.A "M"ind Bending Experience. Power Query for Power BI and Beyond.
A "M"ind Bending Experience. Power Query for Power BI and Beyond.Alex Powers
 
Improve power bi performance
Improve power bi performanceImprove power bi performance
Improve power bi performanceAnnie Xu
 
Riviera Jug - 20/03/2018 - KSQL
Riviera Jug - 20/03/2018 - KSQLRiviera Jug - 20/03/2018 - KSQL
Riviera Jug - 20/03/2018 - KSQLFlorent Ramiere
 
Ruby conf 2011, Create your own rails framework
Ruby conf 2011, Create your own rails frameworkRuby conf 2011, Create your own rails framework
Ruby conf 2011, Create your own rails frameworkPankaj Bhageria
 
Terraform on Oracle Cloud Infrastructure: A Primer for Database Administrators
Terraform on Oracle Cloud Infrastructure: A Primer for Database AdministratorsTerraform on Oracle Cloud Infrastructure: A Primer for Database Administrators
Terraform on Oracle Cloud Infrastructure: A Primer for Database AdministratorsSean Scott
 
Growing Data Analytics at Etsy (Cristopher Bohn)
Growing Data Analytics at Etsy (Cristopher Bohn)Growing Data Analytics at Etsy (Cristopher Bohn)
Growing Data Analytics at Etsy (Cristopher Bohn)Ontico
 

Similar to Schemadoc (20)

Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong Foundations
 
Kaseya Connect 2012 - KASEYA CUSTOM REPORT CREATION
Kaseya Connect 2012 - KASEYA CUSTOM REPORT CREATIONKaseya Connect 2012 - KASEYA CUSTOM REPORT CREATION
Kaseya Connect 2012 - KASEYA CUSTOM REPORT CREATION
 
Model-Driven Software Development - Strategies for Design & Implementation of...
Model-Driven Software Development - Strategies for Design & Implementation of...Model-Driven Software Development - Strategies for Design & Implementation of...
Model-Driven Software Development - Strategies for Design & Implementation of...
 
Strategies for Design & Implementation of Domain-Specific Languages
Strategies for Design & Implementation of Domain-Specific LanguagesStrategies for Design & Implementation of Domain-Specific Languages
Strategies for Design & Implementation of Domain-Specific Languages
 
Geek Sync | Rewriting Bad SQL Code 101
Geek Sync | Rewriting Bad SQL Code 101Geek Sync | Rewriting Bad SQL Code 101
Geek Sync | Rewriting Bad SQL Code 101
 
Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB
 
Physical Design and Development
Physical Design and DevelopmentPhysical Design and Development
Physical Design and Development
 
Cassandra Tutorial
Cassandra TutorialCassandra Tutorial
Cassandra Tutorial
 
BITM3730Week14.pptx
BITM3730Week14.pptxBITM3730Week14.pptx
BITM3730Week14.pptx
 
Client storage
Client storageClient storage
Client storage
 
PostgreSQL
PostgreSQLPostgreSQL
PostgreSQL
 
Introduction to PostgreSQL
Introduction to PostgreSQLIntroduction to PostgreSQL
Introduction to PostgreSQL
 
A "M"ind Bending Experience. Power Query for Power BI and Beyond.
A "M"ind Bending Experience. Power Query for Power BI and Beyond.A "M"ind Bending Experience. Power Query for Power BI and Beyond.
A "M"ind Bending Experience. Power Query for Power BI and Beyond.
 
Improve power bi performance
Improve power bi performanceImprove power bi performance
Improve power bi performance
 
Riviera Jug - 20/03/2018 - KSQL
Riviera Jug - 20/03/2018 - KSQLRiviera Jug - 20/03/2018 - KSQL
Riviera Jug - 20/03/2018 - KSQL
 
Ruby conf 2011, Create your own rails framework
Ruby conf 2011, Create your own rails frameworkRuby conf 2011, Create your own rails framework
Ruby conf 2011, Create your own rails framework
 
Salesforce and sap integration
Salesforce and sap integrationSalesforce and sap integration
Salesforce and sap integration
 
S313431 JPA 2.0 Overview
S313431 JPA 2.0 OverviewS313431 JPA 2.0 Overview
S313431 JPA 2.0 Overview
 
Terraform on Oracle Cloud Infrastructure: A Primer for Database Administrators
Terraform on Oracle Cloud Infrastructure: A Primer for Database AdministratorsTerraform on Oracle Cloud Infrastructure: A Primer for Database Administrators
Terraform on Oracle Cloud Infrastructure: A Primer for Database Administrators
 
Growing Data Analytics at Etsy (Cristopher Bohn)
Growing Data Analytics at Etsy (Cristopher Bohn)Growing Data Analytics at Etsy (Cristopher Bohn)
Growing Data Analytics at Etsy (Cristopher Bohn)
 

Recently uploaded

AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101vincent683379
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Hiroshi SHIBATA
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyUXDXConf
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...marcuskenyatta275
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!Memoori
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsLeah Henrickson
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform EngineeringMarcus Vechiato
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimaginedpanagenda
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FIDO Alliance
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfFIDO Alliance
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jNeo4j
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfFIDO Alliance
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024Stephanie Beckett
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?Mark Billinghurst
 

Recently uploaded (20)

AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4j
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 

Schemadoc

  • 1. Schemadoc Bill Karwin, Percona Inc.
  • 2. Schema Can Be Unclear CREATE TABLE AccountActivity ( Id INT PRIMARY KEY, whose name? Name VARCHAR(100), Status VARCHAR(20), what are the values? EntityNum INT, what’s an entity? Order INT what’s a number? ); commerce, or ordinal? www.percona.com
  • 3. Comments CREATE TABLE AccountActivity ( Id INT PRIMARY KEY, Name VARCHAR(100) COMMENT ‘person who placed the order’, Status VARCHAR(20) COMMENT ‘new, open, or closed’, EntityNum INT COMMENT ‘how many items in the order’, Order INT COMMENT ‘reference to the Orders table’ ) COMMENT ‘any change to e-commerce orders’; www.percona.com
  • 4. Length • Limits increased in MySQL 5.5.3: • Per column: 1024 characters • Per index: 1024 characters • Per table: 2048 characters • Per partition: 80 characters (MySQL 5.6 increases this to 1024) www.percona.com
  • 5. Why don’t we use comments? SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA, TABLE_NAME) = (‘EcommerceDB’, ‘AccountActivity’); SELECT COLUMN_NAME, COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE (TABLE_SCHEMA, TABLE_NAME) = (‘EcommerceDB’, ‘AccountActivity’) ORDER BY ORDINAL_POSITION; SELECT INDEX_NAME, CONCAT(‘(’, GROUP_CONCAT(COLUMN_NAME ORDER BY SEQ_IN_INDEX), ‘)’) AS INDEX_COLUMNS, COMMENT AS INDEX_COMMENT FROM INFORMATION_SCHEMA.STATISTICS WHERE (TABLE_SCHEMA, TABLE_NAME) = (‘EcommerceDB’, ‘AccountActivity’) GROUP BY INDEX_NAME; SELECT PARTITION_NAME, PARTITION_COMMENT FROM INFORMATION_SCHEMA.PARTITIONS WHERE (TABLE_SCHEMA, TABLE_NAME) = (‘EcommerceDB’, ‘AccountActivity’) ORDER BY PARTITION_ORDINAL_POSITION; www.percona.com
  • 6. “Is there a tool for MySQL like javadoc for Java code?” www.percona.com
  • 7. development dba documentation www.percona.com
  • 8. schemadoc www.percona.com
  • 9. Usage $ schemadoc -v h=dbserver,D=EcommerceDB,u=root,p=xxxx Loading metadata... Running online analysis... done. Outputting to html. Rendering pages for tables. done. Rendering pages for views done. Rendering pages for procedures done. Rendering pages for triggers done. Rendering page for schema summary... done. Rendering page for schema link... done. Rendering page for deprecated-list... done. Rendering page for all-index... done. Rendering page for help-doc... done. Rendering page for allschema-frame... done. Rendering page for index... done. www.percona.com
  • 10.
  • 11. hooray. www.percona.com
  • 12. But Wait, There’s More • Parses SQL dump file • Reads from a live MySQL instance • Document many schemas • Update one schema at a time www.percona.com
  • 13. Schema Analysis • Number of indexes and columns per data type • Columns with same name but different type • ENUM columns that aren’t NOT NULL • Use of FLOAT or DOUBLE • Tables with one index per column • Tables with one index over all columns • Tables with no indexes • INT(N) other than default N • Lack of INT UNSIGNED columns www.percona.com
  • 14. Schema Analysis • Tables that look like Entity-Attribute-Value • Tables that look like Polymorphic Associations • Superfluous primary key • Report table with least / most indexes • IP addresses stored in VARCHAR • Excessive use of VARCHAR(255), report actual max string length ...And supports plugins for other checks! www.percona.com
  • 15. yes, we get it. www.percona.com
  • 16. Future of Schemadoc • Integrate with Percona Toolkit library • Read extra metadata (foreign keys) • Show table sizes and growth rates • Show SQL privileges (who has access?) • CLI for adding / updating comments • Batch-mode output • Redesign HTML output with modern look & feel... www.percona.com
  • 17.
  • 18. Future of Schemadoc www.percona.com
  • 19. launchpad.net/ schemadoc www.percona.com
  • 20. Copyright 2012 Bill Karwin www.slideshare.net/billkarwin Released under a Creative Commons 3.0 License: http://creativecommons.org/licenses/by-nc-nd/3.0/ You are free to share - to copy, distribute and transmit this work, under the following conditions: Attribution. Noncommercial. No Derivative Works. You must attribute this You may not use this work You may not alter, work to Bill Karwin. for commercial purposes. transform, or build upon this work. www.percona.com