MySQL Workbench - Data Management and Data Exploration

advertisement
Proseminar
Mohamed El Sherif
Rheinisch-Westfälische Technische Hochschule Aachen
Data Management and Data Exploration Group
Univ.-Prof. Dr. rer. nat. Thomas Seidl
Supervision: Dipl. Ing. Marwan Hassani
 What is MySQL
 History of MySQL
 A Bookstore Example
 MySQL Workbench
 MySQL Storage Engines
 Bibliography
1
What is MySQL
• A Database is a collection of structured data.
• MySQL is a RDBMS (Relational Database
Management System).
2
What is MySQL
• A Database is a collection of structured data.
• MySQL is a RDBMS (Relational Database
Management System).
• It is the world’s most used open source RDBMS (that
runs as a server providing multi-user access to a
number of databases)
• 25% market share in overall database usage
• Other RDBMSs : SQLite, PostgreSQL, Microsoft SQL
Server, Oracle, …
2
History of MySQL
• MySQL is named after co-founder Monty Widenius’s
daughter, My.
• Founded by a Swedish Company called MySQL
AB(Aktie Bolag) in 1995.
• Sold to Sun Microsystems in 2008 then to Oracle in
2010.
3
A Bookstore Example
4
A Bookstore
Example
A simple query to add a table to the Database:
1 CREATE TABLE Book
2 (BookID INT NOT NULL AUTO_INCREMENT ,
3 Title VARCHAR(45) NULL ,
4 AuthorID INT NULL ,
5 Publisher VARCHAR(45) NULL ,
6 ISBN VARCHAR(45) NULL ,
5
A Bookstore
Example
A simple query to add a table to the Database:
1 CREATE TABLE Book
2 (BookID INT NOT NULL AUTO_INCREMENT ,
3 Title VARCHAR(45) NULL ,
4 AuthorID INT NULL ,
5 Publisher VARCHAR(45) NULL ,
6 ISBN VARCHAR(45) NULL ,
7 PRIMARY KEY (BookID) ,
5
A Bookstore
Example
A simple query to add a table to the Database:
1 CREATE TABLE Book
2 (BookID INT NOT NULL AUTO_INCREMENT ,
3 Title VARCHAR(45) NULL ,
4 AuthorID INT NULL ,
5 Publisher VARCHAR(45) NULL ,
6 ISBN VARCHAR(45) NULL ,
7 PRIMARY KEY (BookID) ,
8 FOREIGN KEY (AuthorID) REFERENCES Author (AuthorID)) Engine = InnoDB ;
5
A Bookstore
Example
A Query to the database that returns the first two books that are written by "Rowling",
published by "Bloomsbury"and containing "Harry Potter" in their title
would look as follows:
1
2
3
4
5
6
7
SELECT Book.BookID , Book.Title , Author.First , Author.Last
FROM Book , Publisher , Author
WHERE Book.Publisher = Publisher.PublisherName
AND Book.AuthorID = Author.AuthorID
AND Author.Last = 'Rowling' AND Book.Title LIKE '%Harry Potter%'
AND Publisher.PublisherName='Bloomsbury'
Limit 2 ;
6
A Bookstore
Example
A simpler Query to the database that returns the first two books that are written by
"Rowling", published by "Bloomsbury"and containing "Harry Potter" in their title
would look as follows:
1
2
3
4
SELECT b.BookID , b.Title , Concat ( a.First , ' ' , a .Last ) AS 'Author Name'
FROM Book b natural join Author a
WHERE a.Last ='Rowling' AND b.Title LIKE '%Harry Potter%' AND b.Publisher='Bloomsbury'
Limit 2 ;
7
A Bookstore
Example
A simpler Query to the database that returns the first two books that are written by
"Rowling", published by "Bloomsbury"and containing "Harry Potter" in their title
would look as follows:
1
2
3
4
SELECT b.BookID , b.Title , Concat ( a.First , ' ' , a .Last ) AS 'Author Name'
FROM Book b natural join Author a
WHERE a.Last ='Rowling' AND b.Title LIKE '%Harry Potter%' AND b.Publisher='Bloomsbury'
Limit 2 ;
BookID
Title
Author Name
1
Harry Potter and the Philosopher’s Stone
J.K. Rowling
2
Harry Potter and the Chamber of Secrets
J.K. Rowling
7
Communicating with the Server
storing your data
3 Ways to communicate with the MySQL server which is storing your
data:
• MySQL Workbench (or any other MySQL GUI Tool)
• MySQL Command Line
• In programming code (ODBC, JDBC)
MySQL Command Line
MySQL Workbench
8
MySQL Workbench
SQL Development
•
Execute SQL queries .(Add Tables, Edit Data,..)
9
MySQL Workbench
Data Modeling
•
Visualize stored tables in a database. (EER-Model)
10
MySQL Workbench DEMO
11
MySQL Storage Engines
•
•
A storage engine is an underlying software that a RDBMS uses to manage the data in its
database.
MySQL offers a variety of storage engines that can be used in the same database.
12
MySQL Storage Engines
•
•
•
•
A storage engine is an underlying software that a RDBMS uses to manage the data in its
database.
MySQL offers a variety of storage engines that can be used in the same database.
A transaction is a collection of operations that are combined in one statement. This
statement is either fully executed or not executed at all.
Locking is used in databases to prevent multiple users accessing data concurrently in order
not to invalidate or corrupt the data.
12
MySQL Storage Engines
Storage Engine
Transactions
Locking Granularities
Storage Limits
InnoDB
Yes
Row Locks
64TB
MyISAM
No
Table Locks
256TB
Memory
No
Table Locks
RAM
Baron Schwartz, Peter Zaitsev. High Performace MySQL
13
Bibliography
• Baron Schwartz, Peter Zaitsev.
High Performance MySQL
• MySQL Developers. MySQL 5.6 Reference
Manual, 2012.
• Russel J.T. Dyer, Lars Schulten.
MySQL In a Nutshell
• http://www.mysql.com/whymysql/marketshare/
• Di Giacomo,M. MySQL lessons learned on a
digital library, May 2005
Question Time
Thank you for your attention
Download