Professional Documents
Culture Documents
Mysql PPT 1
Mysql PPT 1
"Orders" table:
OrderID OrderNumber PersonID
PersonID
1 77895 3 Foreign
2 44678 3 key
3 22456 2
4 24562 1
ACID properties
Define relational database transactions -
Atomicity: All the elements that make up a complete database
transaction.
Consistency: Defines the rules for maintaining data points in a
correct state after a transaction.
Isolation: Keeps the effect of a transaction invisible to others until
it is committed, to avoid confusion.
Durability: Ensures that data changes become permanent once the
transaction is committed.
Structured Query Language
Structured Query Language is a standard Database
language which is used to create, maintain and
retrieve the relational database.
A programming language for relational databases.
Structured Query Language
Structured: The distinction between
Logical data structure:
Data tables, views, indexes
Operation: Application to specify the content it needs.
Physical storage structures:
Stored data
Operation: How the data shall be accessed.
Database administrators can manage physical data storage without
affecting access to that data as a logical structure.
Eg: Renaming a database file will not affect the tables stored in it.
contd…
Example command :
mysql> show engines;
Types of Storage Engines
Engines Description
InnoDB This is the default storage engine for MySQL 5.5 and higher. It provides transaction-
safe (ACID compliant) tables, supports FOREIGN KEY referential-integrity
constraints. It supports commit, rollback, and crash-recovery capabilities to protect
data. It also support row-level locking (filtering out the rows). It's "consistent
nonlocking reads" increases performance when used in a multiuser environment. It
stores data in clustered indexes which reduces I/O for queries based on primary
keys.
MyISAM This storage engine, manages non transactional tables (data warehouses) huge
table with minimal write operations, provides high-speed storage and retrieval,
supports full text searching. Table level locking,
MEMORY Provides in-memory tables, formerly known as HEAP. It stores all data in RAM for
faster access than storing data on disks. Useful for quick looks up of reference and
other identical data. Non transactional.
MERGE Groups more than one similar MyISAM tables to be treated as a single table, can
handle non transactional tables, included by default.
EXAMPLE You can create tables with this engine, but can not store or fetch data. Purpose of
this is to teach developers about how to write a new storage engine.
ARCHIVE Used to store a large amount of historical data, does not support indexes,
transactional data, compresses data quickly upon insertion.
CSV Stores data in Comma Separated Value format in a text file.
BLACKHOLE Accepts data to store but always returns empty. Used in performance tests.
FEDERATED Stores data in a remote database providing a distributed data environment.
Specifying and Altering storage
engines
The storage engine is specified at the time of the table creation.
The ENGINE keyword specifies the storage engine used for this
particular table.
If we do not specify the storage engine explicitly, then the
default storage engine is used.
MySQL Front ends
Tools for managing MySQL
Building and manipulating data within MySQL
database.
GUI Tools
MySQL Workbench, SequelPro, DBVisualizer, and
the Navicat DB Admin Tool.
MySQL workbench
Versions
MySQL Community Server (Open Source).
MySQL Enterprise Server (Proprietary).
Latest:
MySQL Community Server 8.0.26
MySQL workbench version :
- https://downloads.mysql.com/archives/workbench/
Ubuntu 20.04 8.0.20 (mysql-workbench-
community_8.0.20-
1ubuntu20.04_amd64.deb)
Ubuntu 18.04 8.0.19 (mysql-workbench-
community_8.0.19-
1ubuntu18.04_amd64.deb)
Installation of MySQL…
MySQL Client – Server
SQL Request
MySQL Server
MySQL Client
Response
Installing MySQL in Ubuntu
sudo apt install mysql-workbench
Using MySQL Workbench
Create user
Create Database :
mysql> create database database_name;
Example :
mysql> create database student;
Use Database :
mysql> use database_name;
Example :
mysql> use student;
Data Types…
Data Types
MySQL supports these groups of data types:
Numeric
Date & time
String
The integer types differ in their storage. We can choose values that fit our requirements.