SlideShare a Scribd company logo
MySQL Tutorial For Beginners | Relational Database Management System | MySQL Training | Edureka
MySQL DBA Certification Training www.edureka.co/mysql-dba
Topics For Today’s Session
Structured Query Language
What is Database & DBMS?
MySQL & MySQL Workbench
Entity - Relationship Diagram
SQL Operations & Commands
Normalization
1
3
5
2
4
6
MySQL DBA Certification Training www.edureka.co/mysql-dba
What is Data?
Jessica Dan Gween Bob Stacy Derek Bella
David Charlie Alice Dexter Cassy Janice
Bryan Rachel Jessie Annie Randy Robert
MySQL DBA Certification Training www.edureka.co/mysql-dba
What is Data?
Jessica Dan Gween Bob Stacy Derek Bella
David Charlie Alice Dexter Cassy Janice
Bryan Rachel Jessie Annie Randy Robert
Data in simple words, is distinct pieces of information or collection of facts related to any entity.
MySQL DBA Certification Training www.edureka.co/mysql-dba
Data Is Stored In Database
Jessica
Dan
Gween
Bob
Stacy
Derek
BellaDavid
Charlie
Alice
Dexter
Cassy
Janice
BryanRachel
Jessie
Annie
RandyRobert
MySQL DBA Certification Training www.edureka.co/mysql-dba
Database Management System
A collection of programs which enables users to access database,
manipulate data, and represent data.
A technology to store and retrieve data with utmost efficiency along with
appropriate security measures..
MySQL DBA Certification Training www.edureka.co/mysql-dba
This type supports storage
of new data types.
The data to be stored is in form
of objects.
Object-Oriented
DBMS
Supports many-to many
relations.
This usually results in complex
database structures.
Network
DBMS
Types Of DBMS
Has a style of "parent-child"
relationship of storing data.
It has a structure like a tree with
nodes representing records and
branches representing fields.
Hierarchical
DBMS
This type of DBMS defines
database relationships in form of
tables, also known as relations.
Relational
DBMS
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
SQL
MySQL DBA Certification Training www.edureka.co/mysql-dba
Structured Query Language(SQL)
A standardized programming language which is used for managing relational databases.
With SQL, you can modify databases, add, update or delete rows of data, retrieve subsets
of information from a database and ,any more
Relational databases like MySQL Databases, oracle, Ms SQL Server, Sybase etc use SQL.
Queries and other SQL operations are written as statements. Example: select, insert, add,
update, delete, create, alter, truncate.
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
MySQL
MySQL DBA Certification Training www.edureka.co/mysql-dba
MySQL
A relational database management system
Provides multi-user
access
An Open-Source
Software
Supports-multi storage
engines
Works on many
platforms
MySQL DBA Certification Training www.edureka.co/mysql-dba
Features Of MySQL
Comprehensive
Application
Development
Robust
Transactional
Support
Ease of
Management
High
Performance
Low Total Cost
Of Ownership
Open Source &
24 * 7 Support
Scalability &
Flexibility
High Availability
Secure Data
Protection
MySQL DBA Certification Training www.edureka.co/mysql-dba
MySQL Workbench
MySQL Workbench
Designing and modelling of
database
SQL Development Administration of Server
A visual database designing and modelling access tool for MySQL server relational database.
MySQL DBA Certification Training www.edureka.co/mysql-dba
SQL Command Categories
.
Transaction Control
Language(TCL)
COMMIT, ROLLBACK,
SAVEPOINT
Data Control
Language(DCL)
GRANT, INVOKE
Data Manipulation
Language(DML)
SELECT, INSERT,
UPDATE, DELETE
CREATE, DROP, ALTER
Data Definition Language
(DDL)
Includes the commands which
mainly deal with the
transaction of database.
Includes commands which
mainly deals with the rights,
permissions and other controls
of the database system.
The SQL commands that deals
with the manipulation of data
present in database.
Consists of the commands that
can be used to define the
database schema.
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
Entity-Relationship Diagram
MySQL DBA Certification Training www.edureka.co/mysql-dba
Entity – Relationship Diagram
MySQL DBA Certification Training www.edureka.co/mysql-dba
Entity – Relationship Diagram
Entity & its
Attributes
Composite vs Simple
Single vs Multivalued
A composite attribute can be divided into smaller subparts. These subparts represent individual basic
attributes with their own meanings.
Attributes which are not divisible are simply known as simple or atomic attributes.
Address
Street _address City State Zip
Number Street House_number
Stored vs Derived
Complex Attributes
MySQL DBA Certification Training www.edureka.co/mysql-dba
Entity – Relationship Diagram
Entity & its
Attributes
Composite vs Simple
Single vs Multivalued
Attributes having single value for a particular entity are known as single-valued attributes.
A multivalued attribute may have lower and upper bounds to constrain the number of values allowed for
each individual entity.
Stored vs Derived
Complex Attributes
MySQL DBA Certification Training www.edureka.co/mysql-dba
Entity – Relationship Diagram
Entity & its
Attributes
Composite vs Simple
Single vs Multivalued
Attributes which are derived from the real entities are known as derived attributes.
The stored attribute are such attributes which are already stored in the database and from which the value of
another attribute is derived is called stored attribute.
Stored vs Derived
Complex Attributes
Age Birth_date
MySQL DBA Certification Training www.edureka.co/mysql-dba
Entity – Relationship Diagram
Entity & its
Attributes
Composite vs Simple
Single vs Multivalued
Attributes that can be represented by grouping composite attributes between (), separating the components
with commas, and by displaying the multivalued attributes between [] are known as complex attributes.
Stored vs Derived
Complex Attributes
{Address_phone({Phone(Area_code,Phone_number)},Address(Street_address{Number,Street,
flat_number),City,State,Zip))}
MySQL DBA Certification Training www.edureka.co/mysql-dba
Entity – Relationship Diagram
Entity Types, Entity Sets, Keys & Value Sets
Entity Type
Name:
Entity Set:
EMPLOYEE COMPANY
Name, Age, Salary Name, Headquarters, Owner
e1
(Sahiti Kappagantula, 25, 34K)
e2
(Sanjana Murthy, 35, 56K)
e3
(Jagannath Sharma, 55, 75K)
c1
Initech Computers, Dallas, John
c2
Acme Corporation, London, Alice
MySQL DBA Certification Training www.edureka.co/mysql-dba
Different Types Of Keys In Relational Database
There are mainly 5 types of keys in relational database.
Candidate Key Super Key Foreign KeyAlternate KeyPrimary Key
EMP_NO EMP_NAME EMP_PHONE EMP_STATE EMP_COUNTRY EMP_AGE
1 Rohan 9876543210 Telangana India 23
2 Rohan 9898989811 Punjab India 34
3 Anay 9766612345 Uttar Pradesh India 27
4 Suhana 9788821345 Uttarakhand India 25
EMP_NO DEPT_NO DEPARTMENT_NAME
1 D1 Tech
2 D2 Marketing
1 D2 Marketing
EMPLOYEE
EMPLOYEE_DEPARTMENT
Table 1
Table 2
MySQL DBA Certification Training www.edureka.co/mysql-dba
Different Types Of Keys In Relational Database
Candidate Key
Super Key
Foreign Key
Alternate Key
Primary Key
The minimal set of attribute which can uniquely identify a tuple is known as candidate key.
The value of candidate key will be unique and non-null for every tuple. Also, there can be more than
one candidate key in a relation.
A candidate key can be either a simple or a composite key.
MySQL DBA Certification Training www.edureka.co/mysql-dba
Different Types Of Keys In Relational Database
Candidate Key
Foreign Key
Alternate Key
Primary Key
The set of attributes which can uniquely identify a tuple is known as Super Key.
When you add zero or more attributes to a candidate key, it becomes a super key.
A candidate key is a super key, but obviously the vice-versa is not true.
Super Key
MySQL DBA Certification Training www.edureka.co/mysql-dba
Different Types Of Keys In Relational Database
Candidate Key
Super Key
Foreign Key
Alternate Key
Primary key is also a set of attributes which can be used to uniquely identify every tuple.
There can be more than one candidate key in a relation out of which one can be chosen as primary
key.
Primary Key
MySQL DBA Certification Training www.edureka.co/mysql-dba
Different Types Of Keys In Relational Database
Candidate Key
Super Key
Foreign Key
Primary Key
The candidate key other than primary key is called as alternate key.
Alternate Key
MySQL DBA Certification Training www.edureka.co/mysql-dba
Different Types Of Keys In Relational Database
Candidate Key
Super Key
Alternate Key
Primary Key
If an attribute can only take the values which are present as values of some other attribute, it will
basically be the foreign key to the attribute to which it refers.
The relation which is being referenced is called referenced relation and corresponding attribute is
called referenced attribute and the relation which refers to referenced relation is called referencing
relation and corresponding attribute is called referencing attribute.
Referenced attribute of referencing attribute should be primary key.
Foreign Key
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
Normalization
MySQL DBA Certification Training www.edureka.co/mysql-dba
BCNF
Normalization
A technique that organizes tables in such a way that redundancy and dependency of data is reduced.
3 NF
2 NF
1 NF
MySQL DBA Certification Training www.edureka.co/mysql-dba
Database Normalization Example
Salutation Full Name Address Movies Rented Category
Ms. Alice Johnson 1st Street House No 3 Mission Impossible:
Fallout, Clash of Titans
Action, Action
Mr. David Allen 3rd Street 45 Interstellar, Edge Of
Tomorrow
Sci-Fi, Sci-Fi
Mr. David Allen 7th Avenue Mission Impossible:
Fallout
Action
MySQL DBA Certification Training www.edureka.co/mysql-dba
Normal Forms
First Normal
Form
2 NF
3 NF
BCNF
Each table cell should have a single value. So, basically all the records must be unique.
Salutation Full Name Address Movies Rented
Ms. Alice Johnson
1st Street House
No 3
Mission
Impossible: Fallout
Ms. Alice Johnson
1st Street House
No 3
Clash of Titans
Mr. David Allen 3rd Street 45 Interstellar
Mr. David Allen 3rd Street 45 Edge Of Tomorrow
Mr. David Allen 7th Avenue
Mission
Impossible: Fallout
MySQL DBA Certification Training www.edureka.co/mysql-dba
Normal Forms
1 NF
3 NF
BCNF
Second
Normal Form
Database should be 1NF and should also have single column primary key.
Salutation Full Name Address Movies_Rented
ID Salutation Full Name Address
1 Ms Alice Johnson 1st Street
House No 3
2 Mr David Allen 3rd Street 45
3 Mr David Allen 7th Avenue
ID Movies_Rented
1 Mission Impossible:
Fallout
1 Clash of Titans
2 Interstellar
2 Edge Of Tomorrow
3 Mission Impossible:
Fallout
Table 1
Table 2
MySQL DBA Certification Training www.edureka.co/mysql-dba
Normal Forms
2 NF
3 NF
1 NF
Third
Normal Form
BCNF
The database should be in 2NF and must not have any transitive functional dependencies.
ID Full Name Address Salutation_ID ID Movies_Rented
Salutation_ID Salutation
1 Mr.
2 Ms.
3 Mrs.
4 Dr.
Table 1 Table 2
Table 3
MySQL DBA Certification Training www.edureka.co/mysql-dba
Normal Forms
1 NF
2 NF
3 NF
Boyce-Codd
Normal Form
If your database is in 3rd Normal Form, there would be some scenarios where anomalies would be present, if you
have more than candidate key. Then BCNF comes into role, where you divide your tables further so that there would
be only one candidate key present.
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
MySQL Commands
MySQL DBA Certification Training www.edureka.co/mysql-dba
MySQL Data Types
Numeric
Bit-string
Character-string
Boolean
Timestamp
Date & Time
INT, SMALLINT, FLOAT, REAL , DOUBLE
PRECISION, DECIMAL(i,j)
CHAR(n), VARCHAR(n), CLOB
BIT(n), BIT VARYING(n)
TRUE, FALSE , UNKNOWN
DATE, TIME
DATA
TYPES
MySQL DBA Certification Training www.edureka.co/mysql-dba
Constraints
Constraints in simple terms are the rules that can be applied on the type of data in a table.
NOT NULL
Ensures that a NULL value
cannot be stored in a column
UNIQUE
This constraint makes sure that all
the values in a column are different
CHECK
This constraint ensures that all the values in a column satisfy a
specific condition.
DEFAULT
This constraint consists of a set of default values for a column
when no value is specified.
INDEX This constraint is used to create and retrieve data
from the database very quickly.
MySQL DBA Certification Training www.edureka.co/mysql-dba
MySQL Data Definition Commands
MySQL DBA Certification Training www.edureka.co/mysql-dba
MySQL Data Manipulation Commands
MySQL DBA Certification Training www.edureka.co/mysql-dba
MySQL Data Manipulation Commands
MySQL DBA Certification Training www.edureka.co/mysql-dba
Bitwise
Operators
&, |, ^
Comparison
Operators
==, <, >, <=, >=
<>
Compound
Operators
+=, *=, -=,
/=,%=, &=, ^-=,
|*=
Arithmetic
Operators
+, -, *, /, %
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
Relational Algebra & Relational Calculus
MySQL DBA Certification Training www.edureka.co/mysql-dba
Relational Algebra & Relational Calculus
Unary Relational Operators
SELECT OPERATION PROJECT OPERATION
The SELECT operation is used to choose a
subset of the tuples from a relation that
satisfies a selection condition.
The PROJECT operation, selects certain
columns from the table and discards the
other columns
Selection operator only selects the required tuples but does not display them.
For displaying, data projection operator is used.
RENAME OPERATION
RENAME is a unary operation used for
renaming attributes of a relation
MySQL DBA Certification Training www.edureka.co/mysql-dba
Relational Algebra & Relational Calculus
Set Operations
UNION
Combines rows from both
the queries
INTERSECT
Keeps only those rows which
are common in both the
queries.
MINUS
Keeps rows from the left query
which are not included in the
right query
LEFT QUERY RIGHT QUERY FINAL RESULT
MySQL DBA Certification Training www.edureka.co/mysql-dba
Relational Algebra & Relational Calculus
Set Operations
UNION
Combines rows from both
the queries
INTERSECT
Keeps only those rows which
are common in both the
queries.
MINUS
Keeps rows from the left query
which are not included in the
right query
LEFT QUERY RIGHT QUERY FINAL RESULT
MySQL DBA Certification Training www.edureka.co/mysql-dba
Relational Algebra & Relational Calculus
Set Operations
CARTESIAN PRODUCT (CROSS PRODUCT) OPERATION
Cross product between 2 relations (A & B) will result all the attributes of A followed by each attribute of B. So, each record of A will pair with
every record of B.
A
(Name Age Sex)
-------------------------
Shanaya 34 F
Atul 21 M
Sona 23 F
B
(Id Department)
-------------------------
1 Tech
2 Marketing
A X B
(Name Age Sex Id Department
--------------------------------------------------------
Shanaya 34 F 1 Tech
Shanaya 34 F 2 Marketing
Atul 21 M 1 Tech
Atul 21 M 2 Marketing
Sona 23 F 1 Tech
Sona 23 F 2 Marketing
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
Nested Queries
MySQL DBA Certification Training www.edureka.co/mysql-dba
Nested Queries
Nested queries are SQL queries which have an outer query and inner subquery. The subquery is a query nested within another query such as
SELECT, INSERT, UPDATE or DELETE.
SELECT lastname, firstname
FROM employees
WHERE addressCode IN (SELECT addressCode
FROM office
WHERE country = “INDIA”)
OUTER QUERY SUBQUERY OR INNER QUERY
MySQL DBA Certification Training www.edureka.co/mysql-dba
Relational Algebra & Relational Calculus
Binary Relational Operators
JOIN OPERATION
NATURAL JOIN
CONDITIONAL JOIN
MySQL DBA Certification Training www.edureka.co/mysql-dba
Relational Algebra & Relational Calculus
Binary Relational Operators
JOIN OPERATION
NATURAL JOIN
CONDITIONAL JOIN
If you perform Natural join between two or more relations, then the result will be a set
of all combination of tuples which have equal common attributes.
Department
(Dept_name Manager_name)
-------------------------
IT Anay
Sales Soniya
Product Vishal
Employee
(Name Id Dept_name)
-------------------------
Shanaya 134 IT
Atul 221 Sales
Sona 523 Marketing
Abhay 123 IT Employee >< Department
(Name Id Dept_name Manager)
-------------------------
Shanaya 134 IT Anay
Atul 221 Sales Soniya
Abhay 123 IT Anay
MySQL DBA Certification Training www.edureka.co/mysql-dba
Relational Algebra & Relational Calculus
Binary Relational Operators
JOIN OPERATION
NATURAL JOIN
CONDITIONAL JOIN
A Conditional join works similar to natural join. In a natural join, the default condition is
equal between common attribute while in conditional join we can specify the any
condition such as greater than, less than, or not equal.
A
(Id Sex Marks)
-------------------------
1 F 46
2 F 55
3 F 60
B
(Id Sex Marks)
-------------------------
10 M 21
11 M 23
12 M 59A.Id A.Sex A.Marks B.Id B.Sex B.Marks
-------------------------
1 F 46 10 M 21
1 F 46 11 M 23
2 F 55 10 M 21
2 F 55 11 M 23
3 F 60 10 M 21
3 F 60 11 M 23
3 F 60 12 M 59
Join Between A and B with condition A.Marks >= B.Marks
MySQL DBA Certification Training www.edureka.co/mysql-dba
SQL JOINS
INNER JOIN FULL JOIN
RIGHT JOINLEFT JOIN
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
Views
MySQL DBA Certification Training www.edureka.co/mysql-dba
Views
A view in SQL is a single table, which is derived from other tables
Query
ROWS
VIEWS
COLUMNS
MySQL DBA Certification Training www.edureka.co/mysql-dba
View Commands
CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
CREATE OR REPLACE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;
DROP VIEW view_name;
CREATE VIEW
UPDATE VIEW
DROP VIEW
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
Triggers
MySQL DBA Certification Training www.edureka.co/mysql-dba
Triggers
Set of SQL statements which are stored in the database catalogue and are executed or fired whenever an event associated with a table occurs.
So, a trigger can be invoked either before or after the data is changed by INSERT, UPDATE or DELETE statement.
AFTER INSERT – activated after data is inserted into the table
BEFORE UPDATE – activated before data in the table is updated
AFTER UPDATE – activated after the data in table is updated
BEFORE DELETE – activated before data is removed from the table
AFTER DELETE – activated after data is removed from the table
BEFORE INSERT – activated before data is inserted into the table
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
Transactions
MySQL DBA Certification Training www.edureka.co/mysql-dba
Transactions
Transactions group a set of tasks into a single execution unit. So, basically each transaction begins with a specific task and ends when all the
tasks in the group successfully complete. A transaction has only two results: success or failure.
SET TRANSACTION
Places a name on a transaction COMMIT
This command saves all the
transactions to the database since
the last COMMIT or ROLLBACK
command.ROLLBACK
This command can be used to
undo transactions since the last
COMMIT or ROLLBACK command
was issued.
SAVEPOINT
Creates points within the groups of
transactions in which to ROLLBACK.
RELEASE SAVEPOINT
This command is used to remove a
SAVEPOINT that you have created. CONTROL TRANSACTIONS
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
Timestamps
MySQL DBA Certification Training www.edureka.co/mysql-dba
Timestamps
This function returns a datetime value based on a date or datetime value.
SELECT TIMESTAMP("2018-10-30");
If there are two arguments specified with this function, then it first adds the second argument to the first, and afterwards returns a datetime
value.
MySQL Tutorial For Beginners | Relational Database Management System | MySQL Training | Edureka

More Related Content

PPT
Mysql
PDF
Introduction to SQL..pdf
PPT
SQL select statement and functions
PPTX
SQL Data types and Constarints.pptx
PPTX
Getting Started with MySQL I
PDF
PPT
Database Objects
PPT
MySql slides (ppt)
Mysql
Introduction to SQL..pdf
SQL select statement and functions
SQL Data types and Constarints.pptx
Getting Started with MySQL I
Database Objects
MySql slides (ppt)

What's hot (20)

PDF
PostgreSQL Tutorial for Beginners | Edureka
PPT
Working with Databases and MySQL
PPTX
SQL for interview
PPS
Introduction to Mysql
PPTX
PostgreSQL- An Introduction
ODP
Introduction to triggers
PPTX
introdution to SQL and SQL functions
PPT
PPTX
Chapter 1 introduction to sql server
PDF
Sql Basics | Edureka
PPTX
Introduction to PostgreSQL
PDF
Relational vs Non Relational Databases
PDF
PostgreSQL Tutorial For Beginners | Edureka
PDF
Top 10 Mistakes When Migrating From Oracle to PostgreSQL
PDF
MySQL Workbench Tutorial | Introduction To MySQL Workbench | MySQL DBA Traini...
PPT
MySQL and its basic commands
PPT
MYSQL.ppt
PDF
Oracle SQL Basics
PPTX
5. stored procedure and functions
PostgreSQL Tutorial for Beginners | Edureka
Working with Databases and MySQL
SQL for interview
Introduction to Mysql
PostgreSQL- An Introduction
Introduction to triggers
introdution to SQL and SQL functions
Chapter 1 introduction to sql server
Sql Basics | Edureka
Introduction to PostgreSQL
Relational vs Non Relational Databases
PostgreSQL Tutorial For Beginners | Edureka
Top 10 Mistakes When Migrating From Oracle to PostgreSQL
MySQL Workbench Tutorial | Introduction To MySQL Workbench | MySQL DBA Traini...
MySQL and its basic commands
MYSQL.ppt
Oracle SQL Basics
5. stored procedure and functions
Ad

Similar to MySQL Tutorial For Beginners | Relational Database Management System | MySQL Training | Edureka (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
sql_data.pdf
PPTX
E-R diagram & SQL
PDF
Relational database management system
PPTX
fundamentals-of-database.pptx hehehehehe
PPTX
Unit 10 - Realtional Databases.pptxxxxxxxxx
PPTX
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
PPT
Fg d
PDF
DATA MANAGEMENT computer science class 12 unit - 3 notes.pdf
PPTX
Relational Database Management System
PDF
Class XII-UNIT III - SQL and MySQL Notes_0.pdf
PDF
ADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsg
PPTX
SQL UNIT FOUR.pptxDiscDiscoverabilitDiscoverability Scorey Scoreoverability S...
PPTX
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
PPTX
SQL-queries-for-Data-Analysts-Updated.pptx
PDF
PPT
Database
PPT
Database intro
MYSQL Presentation for SQL database connectivity
sql_data.pdf
E-R diagram & SQL
Relational database management system
fundamentals-of-database.pptx hehehehehe
Unit 10 - Realtional Databases.pptxxxxxxxxx
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
Fg d
DATA MANAGEMENT computer science class 12 unit - 3 notes.pdf
Relational Database Management System
Class XII-UNIT III - SQL and MySQL Notes_0.pdf
ADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsg
SQL UNIT FOUR.pptxDiscDiscoverabilitDiscoverability Scorey Scoreoverability S...
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
SQL-queries-for-Data-Analysts-Updated.pptx
Database
Database intro
Ad

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
PDF
Top 5 Trending Business Intelligence Tools | Edureka
PDF
Tableau Tutorial for Data Science | Edureka
PDF
Python Programming Tutorial | Edureka
PDF
Top 5 PMP Certifications | Edureka
PDF
Top Maven Interview Questions in 2020 | Edureka
PDF
Linux Mint Tutorial | Edureka
PDF
How to Deploy Java Web App in AWS| Edureka
PDF
Importance of Digital Marketing | Edureka
PDF
RPA in 2020 | Edureka
PDF
Email Notifications in Jenkins | Edureka
PDF
EA Algorithm in Machine Learning | Edureka
PDF
Cognitive AI Tutorial | Edureka
PDF
AWS Cloud Practitioner Tutorial | Edureka
PDF
Blue Prism Top Interview Questions | Edureka
PDF
Big Data on AWS Tutorial | Edureka
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
PDF
Kubernetes Installation on Ubuntu | Edureka
PDF
Introduction to DevOps | Edureka
What to learn during the 21 days Lockdown | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Tableau Tutorial for Data Science | Edureka
Python Programming Tutorial | Edureka
Top 5 PMP Certifications | Edureka
Top Maven Interview Questions in 2020 | Edureka
Linux Mint Tutorial | Edureka
How to Deploy Java Web App in AWS| Edureka
Importance of Digital Marketing | Edureka
RPA in 2020 | Edureka
Email Notifications in Jenkins | Edureka
EA Algorithm in Machine Learning | Edureka
Cognitive AI Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Blue Prism Top Interview Questions | Edureka
Big Data on AWS Tutorial | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Kubernetes Installation on Ubuntu | Edureka
Introduction to DevOps | Edureka

Recently uploaded (20)

PDF
Modernizing your data center with Dell and AMD
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Empathic Computing: Creating Shared Understanding
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Encapsulation theory and applications.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Modernizing your data center with Dell and AMD
Per capita expenditure prediction using model stacking based on satellite ima...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Understanding_Digital_Forensics_Presentation.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Big Data Technologies - Introduction.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Digital-Transformation-Roadmap-for-Companies.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Machine learning based COVID-19 study performance prediction
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Empathic Computing: Creating Shared Understanding
Spectral efficient network and resource selection model in 5G networks
Encapsulation theory and applications.pdf
Network Security Unit 5.pdf for BCA BBA.
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
CIFDAQ's Market Insight: SEC Turns Pro Crypto

MySQL Tutorial For Beginners | Relational Database Management System | MySQL Training | Edureka

  • 2. MySQL DBA Certification Training www.edureka.co/mysql-dba Topics For Today’s Session Structured Query Language What is Database & DBMS? MySQL & MySQL Workbench Entity - Relationship Diagram SQL Operations & Commands Normalization 1 3 5 2 4 6
  • 3. MySQL DBA Certification Training www.edureka.co/mysql-dba What is Data? Jessica Dan Gween Bob Stacy Derek Bella David Charlie Alice Dexter Cassy Janice Bryan Rachel Jessie Annie Randy Robert
  • 4. MySQL DBA Certification Training www.edureka.co/mysql-dba What is Data? Jessica Dan Gween Bob Stacy Derek Bella David Charlie Alice Dexter Cassy Janice Bryan Rachel Jessie Annie Randy Robert Data in simple words, is distinct pieces of information or collection of facts related to any entity.
  • 5. MySQL DBA Certification Training www.edureka.co/mysql-dba Data Is Stored In Database Jessica Dan Gween Bob Stacy Derek BellaDavid Charlie Alice Dexter Cassy Janice BryanRachel Jessie Annie RandyRobert
  • 6. MySQL DBA Certification Training www.edureka.co/mysql-dba Database Management System A collection of programs which enables users to access database, manipulate data, and represent data. A technology to store and retrieve data with utmost efficiency along with appropriate security measures..
  • 7. MySQL DBA Certification Training www.edureka.co/mysql-dba This type supports storage of new data types. The data to be stored is in form of objects. Object-Oriented DBMS Supports many-to many relations. This usually results in complex database structures. Network DBMS Types Of DBMS Has a style of "parent-child" relationship of storing data. It has a structure like a tree with nodes representing records and branches representing fields. Hierarchical DBMS This type of DBMS defines database relationships in form of tables, also known as relations. Relational DBMS
  • 8. Copyright © 2018, edureka and/or its affiliates. All rights reserved. SQL
  • 9. MySQL DBA Certification Training www.edureka.co/mysql-dba Structured Query Language(SQL) A standardized programming language which is used for managing relational databases. With SQL, you can modify databases, add, update or delete rows of data, retrieve subsets of information from a database and ,any more Relational databases like MySQL Databases, oracle, Ms SQL Server, Sybase etc use SQL. Queries and other SQL operations are written as statements. Example: select, insert, add, update, delete, create, alter, truncate.
  • 10. Copyright © 2018, edureka and/or its affiliates. All rights reserved. MySQL
  • 11. MySQL DBA Certification Training www.edureka.co/mysql-dba MySQL A relational database management system Provides multi-user access An Open-Source Software Supports-multi storage engines Works on many platforms
  • 12. MySQL DBA Certification Training www.edureka.co/mysql-dba Features Of MySQL Comprehensive Application Development Robust Transactional Support Ease of Management High Performance Low Total Cost Of Ownership Open Source & 24 * 7 Support Scalability & Flexibility High Availability Secure Data Protection
  • 13. MySQL DBA Certification Training www.edureka.co/mysql-dba MySQL Workbench MySQL Workbench Designing and modelling of database SQL Development Administration of Server A visual database designing and modelling access tool for MySQL server relational database.
  • 14. MySQL DBA Certification Training www.edureka.co/mysql-dba SQL Command Categories . Transaction Control Language(TCL) COMMIT, ROLLBACK, SAVEPOINT Data Control Language(DCL) GRANT, INVOKE Data Manipulation Language(DML) SELECT, INSERT, UPDATE, DELETE CREATE, DROP, ALTER Data Definition Language (DDL) Includes the commands which mainly deal with the transaction of database. Includes commands which mainly deals with the rights, permissions and other controls of the database system. The SQL commands that deals with the manipulation of data present in database. Consists of the commands that can be used to define the database schema.
  • 15. Copyright © 2018, edureka and/or its affiliates. All rights reserved. Entity-Relationship Diagram
  • 16. MySQL DBA Certification Training www.edureka.co/mysql-dba Entity – Relationship Diagram
  • 17. MySQL DBA Certification Training www.edureka.co/mysql-dba Entity – Relationship Diagram Entity & its Attributes Composite vs Simple Single vs Multivalued A composite attribute can be divided into smaller subparts. These subparts represent individual basic attributes with their own meanings. Attributes which are not divisible are simply known as simple or atomic attributes. Address Street _address City State Zip Number Street House_number Stored vs Derived Complex Attributes
  • 18. MySQL DBA Certification Training www.edureka.co/mysql-dba Entity – Relationship Diagram Entity & its Attributes Composite vs Simple Single vs Multivalued Attributes having single value for a particular entity are known as single-valued attributes. A multivalued attribute may have lower and upper bounds to constrain the number of values allowed for each individual entity. Stored vs Derived Complex Attributes
  • 19. MySQL DBA Certification Training www.edureka.co/mysql-dba Entity – Relationship Diagram Entity & its Attributes Composite vs Simple Single vs Multivalued Attributes which are derived from the real entities are known as derived attributes. The stored attribute are such attributes which are already stored in the database and from which the value of another attribute is derived is called stored attribute. Stored vs Derived Complex Attributes Age Birth_date
  • 20. MySQL DBA Certification Training www.edureka.co/mysql-dba Entity – Relationship Diagram Entity & its Attributes Composite vs Simple Single vs Multivalued Attributes that can be represented by grouping composite attributes between (), separating the components with commas, and by displaying the multivalued attributes between [] are known as complex attributes. Stored vs Derived Complex Attributes {Address_phone({Phone(Area_code,Phone_number)},Address(Street_address{Number,Street, flat_number),City,State,Zip))}
  • 21. MySQL DBA Certification Training www.edureka.co/mysql-dba Entity – Relationship Diagram Entity Types, Entity Sets, Keys & Value Sets Entity Type Name: Entity Set: EMPLOYEE COMPANY Name, Age, Salary Name, Headquarters, Owner e1 (Sahiti Kappagantula, 25, 34K) e2 (Sanjana Murthy, 35, 56K) e3 (Jagannath Sharma, 55, 75K) c1 Initech Computers, Dallas, John c2 Acme Corporation, London, Alice
  • 22. MySQL DBA Certification Training www.edureka.co/mysql-dba Different Types Of Keys In Relational Database There are mainly 5 types of keys in relational database. Candidate Key Super Key Foreign KeyAlternate KeyPrimary Key EMP_NO EMP_NAME EMP_PHONE EMP_STATE EMP_COUNTRY EMP_AGE 1 Rohan 9876543210 Telangana India 23 2 Rohan 9898989811 Punjab India 34 3 Anay 9766612345 Uttar Pradesh India 27 4 Suhana 9788821345 Uttarakhand India 25 EMP_NO DEPT_NO DEPARTMENT_NAME 1 D1 Tech 2 D2 Marketing 1 D2 Marketing EMPLOYEE EMPLOYEE_DEPARTMENT Table 1 Table 2
  • 23. MySQL DBA Certification Training www.edureka.co/mysql-dba Different Types Of Keys In Relational Database Candidate Key Super Key Foreign Key Alternate Key Primary Key The minimal set of attribute which can uniquely identify a tuple is known as candidate key. The value of candidate key will be unique and non-null for every tuple. Also, there can be more than one candidate key in a relation. A candidate key can be either a simple or a composite key.
  • 24. MySQL DBA Certification Training www.edureka.co/mysql-dba Different Types Of Keys In Relational Database Candidate Key Foreign Key Alternate Key Primary Key The set of attributes which can uniquely identify a tuple is known as Super Key. When you add zero or more attributes to a candidate key, it becomes a super key. A candidate key is a super key, but obviously the vice-versa is not true. Super Key
  • 25. MySQL DBA Certification Training www.edureka.co/mysql-dba Different Types Of Keys In Relational Database Candidate Key Super Key Foreign Key Alternate Key Primary key is also a set of attributes which can be used to uniquely identify every tuple. There can be more than one candidate key in a relation out of which one can be chosen as primary key. Primary Key
  • 26. MySQL DBA Certification Training www.edureka.co/mysql-dba Different Types Of Keys In Relational Database Candidate Key Super Key Foreign Key Primary Key The candidate key other than primary key is called as alternate key. Alternate Key
  • 27. MySQL DBA Certification Training www.edureka.co/mysql-dba Different Types Of Keys In Relational Database Candidate Key Super Key Alternate Key Primary Key If an attribute can only take the values which are present as values of some other attribute, it will basically be the foreign key to the attribute to which it refers. The relation which is being referenced is called referenced relation and corresponding attribute is called referenced attribute and the relation which refers to referenced relation is called referencing relation and corresponding attribute is called referencing attribute. Referenced attribute of referencing attribute should be primary key. Foreign Key
  • 28. Copyright © 2018, edureka and/or its affiliates. All rights reserved. Normalization
  • 29. MySQL DBA Certification Training www.edureka.co/mysql-dba BCNF Normalization A technique that organizes tables in such a way that redundancy and dependency of data is reduced. 3 NF 2 NF 1 NF
  • 30. MySQL DBA Certification Training www.edureka.co/mysql-dba Database Normalization Example Salutation Full Name Address Movies Rented Category Ms. Alice Johnson 1st Street House No 3 Mission Impossible: Fallout, Clash of Titans Action, Action Mr. David Allen 3rd Street 45 Interstellar, Edge Of Tomorrow Sci-Fi, Sci-Fi Mr. David Allen 7th Avenue Mission Impossible: Fallout Action
  • 31. MySQL DBA Certification Training www.edureka.co/mysql-dba Normal Forms First Normal Form 2 NF 3 NF BCNF Each table cell should have a single value. So, basically all the records must be unique. Salutation Full Name Address Movies Rented Ms. Alice Johnson 1st Street House No 3 Mission Impossible: Fallout Ms. Alice Johnson 1st Street House No 3 Clash of Titans Mr. David Allen 3rd Street 45 Interstellar Mr. David Allen 3rd Street 45 Edge Of Tomorrow Mr. David Allen 7th Avenue Mission Impossible: Fallout
  • 32. MySQL DBA Certification Training www.edureka.co/mysql-dba Normal Forms 1 NF 3 NF BCNF Second Normal Form Database should be 1NF and should also have single column primary key. Salutation Full Name Address Movies_Rented ID Salutation Full Name Address 1 Ms Alice Johnson 1st Street House No 3 2 Mr David Allen 3rd Street 45 3 Mr David Allen 7th Avenue ID Movies_Rented 1 Mission Impossible: Fallout 1 Clash of Titans 2 Interstellar 2 Edge Of Tomorrow 3 Mission Impossible: Fallout Table 1 Table 2
  • 33. MySQL DBA Certification Training www.edureka.co/mysql-dba Normal Forms 2 NF 3 NF 1 NF Third Normal Form BCNF The database should be in 2NF and must not have any transitive functional dependencies. ID Full Name Address Salutation_ID ID Movies_Rented Salutation_ID Salutation 1 Mr. 2 Ms. 3 Mrs. 4 Dr. Table 1 Table 2 Table 3
  • 34. MySQL DBA Certification Training www.edureka.co/mysql-dba Normal Forms 1 NF 2 NF 3 NF Boyce-Codd Normal Form If your database is in 3rd Normal Form, there would be some scenarios where anomalies would be present, if you have more than candidate key. Then BCNF comes into role, where you divide your tables further so that there would be only one candidate key present.
  • 35. Copyright © 2018, edureka and/or its affiliates. All rights reserved. MySQL Commands
  • 36. MySQL DBA Certification Training www.edureka.co/mysql-dba MySQL Data Types Numeric Bit-string Character-string Boolean Timestamp Date & Time INT, SMALLINT, FLOAT, REAL , DOUBLE PRECISION, DECIMAL(i,j) CHAR(n), VARCHAR(n), CLOB BIT(n), BIT VARYING(n) TRUE, FALSE , UNKNOWN DATE, TIME DATA TYPES
  • 37. MySQL DBA Certification Training www.edureka.co/mysql-dba Constraints Constraints in simple terms are the rules that can be applied on the type of data in a table. NOT NULL Ensures that a NULL value cannot be stored in a column UNIQUE This constraint makes sure that all the values in a column are different CHECK This constraint ensures that all the values in a column satisfy a specific condition. DEFAULT This constraint consists of a set of default values for a column when no value is specified. INDEX This constraint is used to create and retrieve data from the database very quickly.
  • 38. MySQL DBA Certification Training www.edureka.co/mysql-dba MySQL Data Definition Commands
  • 39. MySQL DBA Certification Training www.edureka.co/mysql-dba MySQL Data Manipulation Commands
  • 40. MySQL DBA Certification Training www.edureka.co/mysql-dba MySQL Data Manipulation Commands
  • 41. MySQL DBA Certification Training www.edureka.co/mysql-dba Bitwise Operators &, |, ^ Comparison Operators ==, <, >, <=, >= <> Compound Operators +=, *=, -=, /=,%=, &=, ^-=, |*= Arithmetic Operators +, -, *, /, %
  • 42. Copyright © 2018, edureka and/or its affiliates. All rights reserved. Relational Algebra & Relational Calculus
  • 43. MySQL DBA Certification Training www.edureka.co/mysql-dba Relational Algebra & Relational Calculus Unary Relational Operators SELECT OPERATION PROJECT OPERATION The SELECT operation is used to choose a subset of the tuples from a relation that satisfies a selection condition. The PROJECT operation, selects certain columns from the table and discards the other columns Selection operator only selects the required tuples but does not display them. For displaying, data projection operator is used. RENAME OPERATION RENAME is a unary operation used for renaming attributes of a relation
  • 44. MySQL DBA Certification Training www.edureka.co/mysql-dba Relational Algebra & Relational Calculus Set Operations UNION Combines rows from both the queries INTERSECT Keeps only those rows which are common in both the queries. MINUS Keeps rows from the left query which are not included in the right query LEFT QUERY RIGHT QUERY FINAL RESULT
  • 45. MySQL DBA Certification Training www.edureka.co/mysql-dba Relational Algebra & Relational Calculus Set Operations UNION Combines rows from both the queries INTERSECT Keeps only those rows which are common in both the queries. MINUS Keeps rows from the left query which are not included in the right query LEFT QUERY RIGHT QUERY FINAL RESULT
  • 46. MySQL DBA Certification Training www.edureka.co/mysql-dba Relational Algebra & Relational Calculus Set Operations CARTESIAN PRODUCT (CROSS PRODUCT) OPERATION Cross product between 2 relations (A & B) will result all the attributes of A followed by each attribute of B. So, each record of A will pair with every record of B. A (Name Age Sex) ------------------------- Shanaya 34 F Atul 21 M Sona 23 F B (Id Department) ------------------------- 1 Tech 2 Marketing A X B (Name Age Sex Id Department -------------------------------------------------------- Shanaya 34 F 1 Tech Shanaya 34 F 2 Marketing Atul 21 M 1 Tech Atul 21 M 2 Marketing Sona 23 F 1 Tech Sona 23 F 2 Marketing
  • 47. Copyright © 2018, edureka and/or its affiliates. All rights reserved. Nested Queries
  • 48. MySQL DBA Certification Training www.edureka.co/mysql-dba Nested Queries Nested queries are SQL queries which have an outer query and inner subquery. The subquery is a query nested within another query such as SELECT, INSERT, UPDATE or DELETE. SELECT lastname, firstname FROM employees WHERE addressCode IN (SELECT addressCode FROM office WHERE country = “INDIA”) OUTER QUERY SUBQUERY OR INNER QUERY
  • 49. MySQL DBA Certification Training www.edureka.co/mysql-dba Relational Algebra & Relational Calculus Binary Relational Operators JOIN OPERATION NATURAL JOIN CONDITIONAL JOIN
  • 50. MySQL DBA Certification Training www.edureka.co/mysql-dba Relational Algebra & Relational Calculus Binary Relational Operators JOIN OPERATION NATURAL JOIN CONDITIONAL JOIN If you perform Natural join between two or more relations, then the result will be a set of all combination of tuples which have equal common attributes. Department (Dept_name Manager_name) ------------------------- IT Anay Sales Soniya Product Vishal Employee (Name Id Dept_name) ------------------------- Shanaya 134 IT Atul 221 Sales Sona 523 Marketing Abhay 123 IT Employee >< Department (Name Id Dept_name Manager) ------------------------- Shanaya 134 IT Anay Atul 221 Sales Soniya Abhay 123 IT Anay
  • 51. MySQL DBA Certification Training www.edureka.co/mysql-dba Relational Algebra & Relational Calculus Binary Relational Operators JOIN OPERATION NATURAL JOIN CONDITIONAL JOIN A Conditional join works similar to natural join. In a natural join, the default condition is equal between common attribute while in conditional join we can specify the any condition such as greater than, less than, or not equal. A (Id Sex Marks) ------------------------- 1 F 46 2 F 55 3 F 60 B (Id Sex Marks) ------------------------- 10 M 21 11 M 23 12 M 59A.Id A.Sex A.Marks B.Id B.Sex B.Marks ------------------------- 1 F 46 10 M 21 1 F 46 11 M 23 2 F 55 10 M 21 2 F 55 11 M 23 3 F 60 10 M 21 3 F 60 11 M 23 3 F 60 12 M 59 Join Between A and B with condition A.Marks >= B.Marks
  • 52. MySQL DBA Certification Training www.edureka.co/mysql-dba SQL JOINS INNER JOIN FULL JOIN RIGHT JOINLEFT JOIN
  • 53. Copyright © 2018, edureka and/or its affiliates. All rights reserved. Views
  • 54. MySQL DBA Certification Training www.edureka.co/mysql-dba Views A view in SQL is a single table, which is derived from other tables Query ROWS VIEWS COLUMNS
  • 55. MySQL DBA Certification Training www.edureka.co/mysql-dba View Commands CREATE VIEW view_name AS SELECT column1, column2, ... FROM table_name WHERE condition; CREATE OR REPLACE VIEW view_name AS SELECT column1, column2, ... FROM table_name WHERE condition; DROP VIEW view_name; CREATE VIEW UPDATE VIEW DROP VIEW
  • 56. Copyright © 2018, edureka and/or its affiliates. All rights reserved. Triggers
  • 57. MySQL DBA Certification Training www.edureka.co/mysql-dba Triggers Set of SQL statements which are stored in the database catalogue and are executed or fired whenever an event associated with a table occurs. So, a trigger can be invoked either before or after the data is changed by INSERT, UPDATE or DELETE statement. AFTER INSERT – activated after data is inserted into the table BEFORE UPDATE – activated before data in the table is updated AFTER UPDATE – activated after the data in table is updated BEFORE DELETE – activated before data is removed from the table AFTER DELETE – activated after data is removed from the table BEFORE INSERT – activated before data is inserted into the table
  • 58. Copyright © 2018, edureka and/or its affiliates. All rights reserved. Transactions
  • 59. MySQL DBA Certification Training www.edureka.co/mysql-dba Transactions Transactions group a set of tasks into a single execution unit. So, basically each transaction begins with a specific task and ends when all the tasks in the group successfully complete. A transaction has only two results: success or failure. SET TRANSACTION Places a name on a transaction COMMIT This command saves all the transactions to the database since the last COMMIT or ROLLBACK command.ROLLBACK This command can be used to undo transactions since the last COMMIT or ROLLBACK command was issued. SAVEPOINT Creates points within the groups of transactions in which to ROLLBACK. RELEASE SAVEPOINT This command is used to remove a SAVEPOINT that you have created. CONTROL TRANSACTIONS
  • 60. Copyright © 2018, edureka and/or its affiliates. All rights reserved. Timestamps
  • 61. MySQL DBA Certification Training www.edureka.co/mysql-dba Timestamps This function returns a datetime value based on a date or datetime value. SELECT TIMESTAMP("2018-10-30"); If there are two arguments specified with this function, then it first adds the second argument to the first, and afterwards returns a datetime value.