SlideShare a Scribd company logo
Database Overview
Presented By
Abhilash K
1
Contents
2
Contents
8.SQL Functions
9.SQL Joins
10.SQL Sub Queries
11.Peformance Tuning
12.Advanced Concepts
3
Introduction
About DBMS
A database management system (DBMS) is a software for
creating and managing databases. DBMS provides
users/programmers with a systematic way to create,
retrieve, update and manage data.
What is RDBMS
A type of DBMS in which the database is organized and
accessed according to the relationships between data
values. RDBMS are designed to take care of large amounts
of data and also the security of this data
4
RDBMS Have
Tables (relations) that are two dimensional
The tables have rows (records or objects)
The tables have columns (fields or attributes)
The data stored is simple data such as integers, real
numbers, dates or string values
All table columns depend on a primary key to identify the
column
Database – collection of Tables and other objects.
5
SQL
Structured Query Language
SQL Overview
➔ SQL is language component of the RDBMS
➔ SQL essentially has four components
SQL Has 4 essential components
➔ The data definition language : DDL
➔ The data manipulation language : DML
➔ The data control language : DCL
➔ The transaction control language : TCL
6
SQL – Components 1
DDL – Statements used to define the database structure
or schema
➔ CREATE – Creates objects in the database
➔ ALTER – Alters the structure of the database
➔ DROP – Deletes the objects form the database
➔ TRUNCATE – Remove all records from a table, including all spaces
allocated for the records are removed
DML – Statements used to managing data with in schema
objects
➔ SELECT – Retrieve data from the database
➔ INSERT – Insert data into a table
➔ UPDATE - Updates existing data within a table
➔ DELETE - Deletes records from a table,the space for the records
remains
7
SQL – Components 2
DCL – Statement used for data control
➔ GRANT – Give user’s access privileges to database
➔ REVOKE – Withdraw access privileges given the GRANT command
TCL – Manages the changes made by DML
statements
➔ COMMIT – Saves the work done
➔ SAVEPOINT – Identify a point in transaction to which you
can later rollback
➔ ROLLBACK – Restore database to original since the last
➔ SET TRANSACTION – Change transaction options like
isolation level and what rollback segment to use
8
Database Table
Definition
➔ A two dimensional arrangements of rows and columns
used for holding data
A Table
➔ Has unique name
➔ Consists of rows and columns
➔ All values in one column have the same data type
➔ Every column can be used in an SQL statement
9
Creating Table
Syntax
CREATE TABLE table_name
(column1 datatype null/not null,
column2 datatype null/not null,
…)
Each column must have a datatype. The column should
either be defined as "null" or "not null" and if this value is
left blank, the database assumes "null" as the default
10
Creating Table
Specification
➔ NULL
➔ NOT NULL
➔ NOT NULL WITH DEFAULT
When creating a table,one of these attributes is specified for a column
NULL v/s NOT NULL
➔ NULL - Can be interpreted as unknown or not available
Null doesn’t mean empty (blank) or 0 (Zero)
➔ NOT NULL - The user must provide values while inserting a
row (0 or blank is allowed for these columns)
11
Creating Table
NOT NULL WITH DEFAULT
The default value is stored,when a row is inserted without a specified
value for this column.
The default value is
Zero (0) for numeric data fields
Blank [empty] for character data fields
Current date for DATE fields
12
Data Types
Common Data Types in MySQL
char varchar text bigint binary
blob bit int date datetime
decimal enum float numeric ntext
nvarchar nchar real double
mediumtext smallinttimestamp
datetime(x)
time
tinyintjson
13
Integrity Constraints
Primary Key
Foreign Key
Unique Key
NOT NULL
Check
14
Integrity Constraints
Primary Key
➔ A primary key is a single field or combination of fields
that uniquely defines a record
➔ A table can have only one primary key
➔ A primary key can be defined in either a CREATE TABLE
statement or an ALTER TABLE statement
15
Integrity Constraints
Foreign Key
➔ A foreign key means that values in one table must also
appear in another table
➔ The foreign key in the child table will generally
reference a primary key in the parent table
➔ A foreign key can be defined in either a CREATE TABLE
statement or an ALTER TABLE statement
16
Integrity Constraints
Unique Key
➔ A unique constraint is a single field or combination of
fields that uniquely defines a record.
➔ Some of the fields can contain null values as long as
the combination of values is unique.
➔ A unique constraint can be defined in either a CREATE
TABLE statement or an ALTER TABLE statement
17
Integrity Constraints
What is the difference between Primary Key and Unique
Key?
18
Primary Key Unique Constraint
None of the fields that are
part of the primary key can
contain a null value
Some of the fields that are
part of the unique
constraint can contain null
values as long as the
combination of values is
unique
Integrity Constraints
NOT NULL
➔ NOT NULL constraints are in-line constraints that
indicate that a column can not contain NULL values
CHECK
➔ Check constraints validate that values in a given
column meet a specific criteria
19
IDE/Tools
MySQL Server Tools
➔ Toad for MySQL
➔ SQL Yog
➔ phpMyAdmin
➔ MySQL Administrator
➔ MySQL Query Browser
➔ MySQL WorkBench
20
Structure of SQL Queries
SELECT - column names / arithmetic expressions / literals
/ scalar functions / column functions
FROM - table names or view names
WHERE - conditions
GROUP BY - column names
HAVING - conditions
ORDER BY - column names
21
Table Aliases
Table Alias
➔ The use of table aliases means to rename a table in a
particular SQL statement
➔ The renaming is a temporary change
➔ The actual table name does not change in the
database
22
Comparison Operators
In the WHERE clause
➔ Equal =
➔ Not Equal != or <>
➔ Less <
➔ Less or Equal < =
➔ Greater >
➔ Greater or Equal > =
23
Boolean Operators
Boolean Operators
➔ AND
➔ OR
➔ NOT
24
Additional Operators
Additional Operators
➔ IN
➔ NOT IN
➔ BETWEEN
➔ NOT BETWEEN
➔ LIKE
➔ NOT LIKE
➔ IS NULL
➔ IS NOT NULL
25
Distinct
The DISTINCT clause
➔ Allows you to remove duplicates from the result set
➔ The DISTINCT clause can only be used with select
statements.
The syntax
➔ SELECT DISTINCT column_name FROM table_name
26
Table Joins
JOIN
A join is used to combine rows from multiple tables
Different types of joins
➔ INNER JOIN
➔ OUTER JOIN
➢ LEFT JOIN
➢ RIGHT JOIN
➢ FULL JOIN
➔ CARTESIAN JOIN
27
WHERE Clause
WHERE
The WHERE clause allows you to filter the results from an
SQL statement
E.g.
SELECT *
FROM supplier
WHERE supplier_name = ‘ABC’
28
GROUP Functions
Group functions
Return results based on groups of rows, rather than on
single rows
Main Group functions
➔ COUNT
➔ SUM
➔ MIN
➔ MAX
➔ AVG
29
GROUP Functions
COUNT function - returns the number of rows in a query
SELECT COUNT(expression) FROM table_name;
SUM Function - returns the summed value of an
expression
SELECT SUM(expression ) FROM table_name;
MIN Function - returns the minimum value of an
expression
SELECT MIN(expression ) FROM table_name;
MAX function - returns the maximum value of an
expression
SELECT MAX(expression ) FROM table_name;
AVG Function - returns the average value of an expression
SELECT AVG(expression) FROM table_name;
30
Grouping
GROUP BY Clause
Can be used in a SELECT statement to collect data
across multiple records and group the results by one or
more columns
The syntax
SELECT column1,column2,
aggregate_function(expression)
FROM tables
WHERE predicates
GROUP BY column1, column2;
31
Having Clause
HAVING clause
➔ Used in combination with the GROUP BY clause.
➔ It can be used in a SELECT statement to filter the
records that a GROUP BY returns.
The syntax :
SELECT column1, column2, ... column_n,
aggregate_function (expression)
FROM tables
WHERE predicates
GROUP BY column1, column2, ... column_n
HAVING condition1 ... condition_n;
32
ORDER BY Clause
ORDER BY
Allows to sort the records in your result set
The ORDER BY clause can only be used in SELECT
statements
The syntax :
SELECT columns FROM table
WHERE predicate
ORDER BY column ASC/DESC;
ASC indicates ascending order. (default)
DESC indicates descending order.
33
UNION and UNION ALL
UNION
➔ Allows to combine the result sets of 2 or more "select"
queries
➔ It removes duplicate rows between the various
"select" statements
➔ Each SQL statement within the UNION query must
have the same number of fields in the result sets with
similar data types
The syntax :
Select field1, field2, . field_n From tables
UNION
Select field1, field2, . field_n From tables;
34
UNION and UNION ALL
UNION ALL
➔ Allows to combine the result sets of 2 or more "select“
queries
➔ It returns all rows (even if the row exists in more than
one of the "select" statements)
➔ Each SQL statement within the UNION ALL query
must have the same number of fields in the result
sets with similar data types
The syntax :
Select field1, field2, . field_n From tables
UNION ALL
Select field1, field2, . field_n From tables;
35
Sub Query
Subquery
Is a query within a query [SELECT]
Different Types
➔ Stand alone [independent existence]
➔ Co-related [dependent on outer select]
36
INSERT, UPDATE and DELETE
INSERT - Allows to insert a single record or multiple
records into a table.
INSERT INTO table (column-1, column-2, ... column-n)
VALUES (value-1, value-2, ... value-n);
UPDATE - Allows to update a single record or multiple
records in a table.
UPDATE table SET column = expression
WHERE predicate;
DELETE - Allows to delete a single record or multiple
records from a table.
DELETE FROM table WHERE predicate;
Note : “i-am-a-dummy” configuration
37
Database Design-Thump Rule
A table generally should have an identifier.
A table should store only data for a single type of entity.
A table should avoid nullable columns.
Table should not have repeating values or columns.
Keep columns as short as possible. e.g. Use int for bigint
38
Person Schema Design
39
Person Schema Design
40
Normalization
Normalizing a logical database design involves using
formal methods to separate the data into multiple, related
tables
A greater number of narrow tables (with fewer columns)
is characteristic of a normalized database
41
Benefits of Normalization
Faster sorting and index creation.
A larger number of clustered indexes.
Narrower and more compact indexes.
Fewer indexes per table, which improves the performance
of INSERT, UPDATE, and DELETE statements.
Fewer null values and less opportunity for inconsistency,
which increase database compactness.
42
INDEX
As the name indicates, indexes are used to speed up the
SELECT queries.
Types :
➔ Clustered : Created by default when a primary key is
created on the table.
➔ Non Clustered [Secondary] : All indexes other than the
clustered index are known as secondary indexes.
● Restrictions :
✔ A table can contain a maximum of 64 secondary indexes.
✔ A maximum of 16 columns only permitted for multicolumn
indexes.
43
INDEX
Disadvantages :
✔ The index slows down the speed of writing queries, such
as INSERT, UPDATE and DELETE. So more number of
indexes will lead to sluggishness of write operations.
✔ when we create index, it takes up disk space. the index
file would grow much more quickly than the data file.
44
Performance Tuning
EXPLAIN EXTENDED SELECT *
FROM stray_intakes
WHERE nid = 1209159 AND gid = 464;
table
➔ The table to which the row of output refers.
45
Performance Tuning
type
The join type. Possible join types are listed below,
ranked fastest to slowest:
➔ system - The table is a system table with only one row.
➔ const - The table has at most one matching row. A const
query is fast because the table is read only once.
➔ eq_ref - No more than one row will be read from this table.
This type is used when all columns of an index are used in
the query, and the index is UNIQUE or a PRIMARY KEY.
➔ ref - All matching rows will be read from this table. This is
used when an index is neither UNIQUE nor a PRIMARY.
46
Performance Tuning
➔ range - Only rows in a given range will be retrieved from
this table, using an index to select the rows.
➔ index - A full scan of the index will be performed for each
combination of rows from previous tables. This is the
same as an ALL join type except only the index is
scanned.
➔ ALL - A full scan of the table will be performed for each
combination of rows from previous tables. ALL joins
should be avoided by adding an index.
47
Performance Tuning
possible_keys
Lists which indexes MySQL could use to find the rows
in this table. When there are no relevant indexes,
possible_keys is NULL. This indicates that you can improve
the performance of your query by adding an index.
key
Lists the actual index that MySQL chose. It is NULL if
no index was chosen.
rows
Lists the number of rows that MySQL needs to
examine from the table to execute the query.
48
Advanced Concepts
Information_Schema
MySQL Engines
Stored Procedures, Functions, Views
Backup and Restore of Databases
MySQL Replication
MySQL Cluster
49
50
Thanks a lot for your time…
Questions?

More Related Content

What's hot

Sql commands
Sql commandsSql commands
Sql commands
Pooja Dixit
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
Mohd Tousif
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
TechandMate
 
Mysql
MysqlMysql
Mysql
TSUBHASHRI
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
VENNILAV6
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
Al-Mamun Sarkar
 
SQL commands
SQL commandsSQL commands
SQL commands
GirdharRatne
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
Belle Wx
 
SQL
SQLSQL
Oracle: DDL
Oracle: DDLOracle: DDL
Oracle: DDL
DataminingTools Inc
 
Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Language
pandey3045_bit
 
DML Commands
DML CommandsDML Commands
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
Smriti Jain
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
Stewart Rogers
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
Swapnali Pawar
 
Sql DML
Sql DMLSql DML
Sql DML
Vikas Gupta
 
A must Sql notes for beginners
A must Sql notes for beginnersA must Sql notes for beginners
A must Sql notes for beginners
Ram Sagar Mourya
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
1keydata
 

What's hot (20)

Sql commands
Sql commandsSql commands
Sql commands
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
Mysql
MysqlMysql
Mysql
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
 
SQL commands
SQL commandsSQL commands
SQL commands
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
SQL
SQLSQL
SQL
 
Oracle: DDL
Oracle: DDLOracle: DDL
Oracle: DDL
 
Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Language
 
DML Commands
DML CommandsDML Commands
DML Commands
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
 
Sql DML
Sql DMLSql DML
Sql DML
 
A must Sql notes for beginners
A must Sql notes for beginnersA must Sql notes for beginners
A must Sql notes for beginners
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
 

Similar to Database Overview

DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
jainendraKUMAR55
 
SQL Query
SQL QuerySQL Query
SQL Query
Imam340267
 
DBMS.pdf
DBMS.pdfDBMS.pdf
DBMS.pdf
Rishab Saini
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
Abrar ali
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
DraguClaudiu
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
PavithSingh
 
Module 3
Module 3Module 3
Module 3
cs19club
 
Interview Questions.pdf
Interview Questions.pdfInterview Questions.pdf
Interview Questions.pdf
TarunKumar893717
 
Adbms
AdbmsAdbms
Adbms
jass12345
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SakkaravarthiS1
 
Lab
LabLab
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
SANTOSH RATH
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic Concepts
Tony Wong
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
Sankhya_Analytics
 
Introduction to Structured Query Language (SQL).ppt
Introduction to Structured Query Language (SQL).pptIntroduction to Structured Query Language (SQL).ppt
Introduction to Structured Query Language (SQL).ppt
Ashwini Rao
 
MySQL notes - Basic Commands and Definitions
MySQL notes - Basic Commands and DefinitionsMySQL notes - Basic Commands and Definitions
MySQL notes - Basic Commands and Definitions
DeepakDeedarSingla
 
Sql basics
Sql  basicsSql  basics
Sql basics
Genesis Omo
 
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Views, Triggers, Functions, Stored Procedures,  Indexing and JoinsViews, Triggers, Functions, Stored Procedures,  Indexing and Joins
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
baabtra.com - No. 1 supplier of quality freshers
 
SQL | DML
SQL | DMLSQL | DML
SQL | DML
To Sum It Up
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
Vibrant Technologies & Computers
 

Similar to Database Overview (20)

DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
SQL Query
SQL QuerySQL Query
SQL Query
 
DBMS.pdf
DBMS.pdfDBMS.pdf
DBMS.pdf
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
 
Module 3
Module 3Module 3
Module 3
 
Interview Questions.pdf
Interview Questions.pdfInterview Questions.pdf
Interview Questions.pdf
 
Adbms
AdbmsAdbms
Adbms
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
 
Lab
LabLab
Lab
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic Concepts
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
 
Introduction to Structured Query Language (SQL).ppt
Introduction to Structured Query Language (SQL).pptIntroduction to Structured Query Language (SQL).ppt
Introduction to Structured Query Language (SQL).ppt
 
MySQL notes - Basic Commands and Definitions
MySQL notes - Basic Commands and DefinitionsMySQL notes - Basic Commands and Definitions
MySQL notes - Basic Commands and Definitions
 
Sql basics
Sql  basicsSql  basics
Sql basics
 
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Views, Triggers, Functions, Stored Procedures,  Indexing and JoinsViews, Triggers, Functions, Stored Procedures,  Indexing and Joins
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
 
SQL | DML
SQL | DMLSQL | DML
SQL | DML
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
 

More from Livares Technologies Pvt Ltd

Web Performance Optimization
Web Performance OptimizationWeb Performance Optimization
Web Performance Optimization
Livares Technologies Pvt Ltd
 
Supervised Machine Learning
Supervised Machine LearningSupervised Machine Learning
Supervised Machine Learning
Livares Technologies Pvt Ltd
 
Software Architecture Design
Software Architecture DesignSoftware Architecture Design
Software Architecture Design
Livares Technologies Pvt Ltd
 
Automation using Appium
Automation using AppiumAutomation using Appium
Automation using Appium
Livares Technologies Pvt Ltd
 
Bubble(No code Tool)
Bubble(No code Tool)Bubble(No code Tool)
Bubble(No code Tool)
Livares Technologies Pvt Ltd
 
Unsupervised Machine Learning
Unsupervised Machine LearningUnsupervised Machine Learning
Unsupervised Machine Learning
Livares Technologies Pvt Ltd
 
Developing Secure Apps
Developing Secure AppsDeveloping Secure Apps
Developing Secure Apps
Livares Technologies Pvt Ltd
 
Micro-Frontend Architecture
Micro-Frontend ArchitectureMicro-Frontend Architecture
Micro-Frontend Architecture
Livares Technologies Pvt Ltd
 
Apache J meter
Apache J meterApache J meter
Introduction to Angular JS
Introduction to Angular JSIntroduction to Angular JS
Introduction to Angular JS
Livares Technologies Pvt Ltd
 
An Insight into Quantum Computing
An Insight into Quantum ComputingAn Insight into Quantum Computing
An Insight into Quantum Computing
Livares Technologies Pvt Ltd
 
Just in Time (JIT)
Just in Time (JIT)Just in Time (JIT)
Just in Time (JIT)
Livares Technologies Pvt Ltd
 
Introduction to Bitcoin
Introduction to Bitcoin Introduction to Bitcoin
Introduction to Bitcoin
Livares Technologies Pvt Ltd
 
Data Mining Technniques
Data Mining TechnniquesData Mining Technniques
Data Mining Technniques
Livares Technologies Pvt Ltd
 
Facade Design Pattern
Facade Design PatternFacade Design Pattern
Facade Design Pattern
Livares Technologies Pvt Ltd
 
Manual Vs Automation Testing
Manual Vs Automation TestingManual Vs Automation Testing
Manual Vs Automation Testing
Livares Technologies Pvt Ltd
 
Screenless display
Screenless displayScreenless display
Screenless display
Livares Technologies Pvt Ltd
 
An Introduction to Machine Learning
An Introduction to Machine LearningAn Introduction to Machine Learning
An Introduction to Machine Learning
Livares Technologies Pvt Ltd
 
An Introduction to Face Detection
An Introduction to Face DetectionAn Introduction to Face Detection
An Introduction to Face Detection
Livares Technologies Pvt Ltd
 
Smart water meter solutions using LoRa WAN - Troncart
Smart water meter solutions using LoRa WAN - TroncartSmart water meter solutions using LoRa WAN - Troncart
Smart water meter solutions using LoRa WAN - Troncart
Livares Technologies Pvt Ltd
 

More from Livares Technologies Pvt Ltd (20)

Web Performance Optimization
Web Performance OptimizationWeb Performance Optimization
Web Performance Optimization
 
Supervised Machine Learning
Supervised Machine LearningSupervised Machine Learning
Supervised Machine Learning
 
Software Architecture Design
Software Architecture DesignSoftware Architecture Design
Software Architecture Design
 
Automation using Appium
Automation using AppiumAutomation using Appium
Automation using Appium
 
Bubble(No code Tool)
Bubble(No code Tool)Bubble(No code Tool)
Bubble(No code Tool)
 
Unsupervised Machine Learning
Unsupervised Machine LearningUnsupervised Machine Learning
Unsupervised Machine Learning
 
Developing Secure Apps
Developing Secure AppsDeveloping Secure Apps
Developing Secure Apps
 
Micro-Frontend Architecture
Micro-Frontend ArchitectureMicro-Frontend Architecture
Micro-Frontend Architecture
 
Apache J meter
Apache J meterApache J meter
Apache J meter
 
Introduction to Angular JS
Introduction to Angular JSIntroduction to Angular JS
Introduction to Angular JS
 
An Insight into Quantum Computing
An Insight into Quantum ComputingAn Insight into Quantum Computing
An Insight into Quantum Computing
 
Just in Time (JIT)
Just in Time (JIT)Just in Time (JIT)
Just in Time (JIT)
 
Introduction to Bitcoin
Introduction to Bitcoin Introduction to Bitcoin
Introduction to Bitcoin
 
Data Mining Technniques
Data Mining TechnniquesData Mining Technniques
Data Mining Technniques
 
Facade Design Pattern
Facade Design PatternFacade Design Pattern
Facade Design Pattern
 
Manual Vs Automation Testing
Manual Vs Automation TestingManual Vs Automation Testing
Manual Vs Automation Testing
 
Screenless display
Screenless displayScreenless display
Screenless display
 
An Introduction to Machine Learning
An Introduction to Machine LearningAn Introduction to Machine Learning
An Introduction to Machine Learning
 
An Introduction to Face Detection
An Introduction to Face DetectionAn Introduction to Face Detection
An Introduction to Face Detection
 
Smart water meter solutions using LoRa WAN - Troncart
Smart water meter solutions using LoRa WAN - TroncartSmart water meter solutions using LoRa WAN - Troncart
Smart water meter solutions using LoRa WAN - Troncart
 

Recently uploaded

Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 

Recently uploaded (20)

Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 

Database Overview

  • 3. Contents 8.SQL Functions 9.SQL Joins 10.SQL Sub Queries 11.Peformance Tuning 12.Advanced Concepts 3
  • 4. Introduction About DBMS A database management system (DBMS) is a software for creating and managing databases. DBMS provides users/programmers with a systematic way to create, retrieve, update and manage data. What is RDBMS A type of DBMS in which the database is organized and accessed according to the relationships between data values. RDBMS are designed to take care of large amounts of data and also the security of this data 4
  • 5. RDBMS Have Tables (relations) that are two dimensional The tables have rows (records or objects) The tables have columns (fields or attributes) The data stored is simple data such as integers, real numbers, dates or string values All table columns depend on a primary key to identify the column Database – collection of Tables and other objects. 5
  • 6. SQL Structured Query Language SQL Overview ➔ SQL is language component of the RDBMS ➔ SQL essentially has four components SQL Has 4 essential components ➔ The data definition language : DDL ➔ The data manipulation language : DML ➔ The data control language : DCL ➔ The transaction control language : TCL 6
  • 7. SQL – Components 1 DDL – Statements used to define the database structure or schema ➔ CREATE – Creates objects in the database ➔ ALTER – Alters the structure of the database ➔ DROP – Deletes the objects form the database ➔ TRUNCATE – Remove all records from a table, including all spaces allocated for the records are removed DML – Statements used to managing data with in schema objects ➔ SELECT – Retrieve data from the database ➔ INSERT – Insert data into a table ➔ UPDATE - Updates existing data within a table ➔ DELETE - Deletes records from a table,the space for the records remains 7
  • 8. SQL – Components 2 DCL – Statement used for data control ➔ GRANT – Give user’s access privileges to database ➔ REVOKE – Withdraw access privileges given the GRANT command TCL – Manages the changes made by DML statements ➔ COMMIT – Saves the work done ➔ SAVEPOINT – Identify a point in transaction to which you can later rollback ➔ ROLLBACK – Restore database to original since the last ➔ SET TRANSACTION – Change transaction options like isolation level and what rollback segment to use 8
  • 9. Database Table Definition ➔ A two dimensional arrangements of rows and columns used for holding data A Table ➔ Has unique name ➔ Consists of rows and columns ➔ All values in one column have the same data type ➔ Every column can be used in an SQL statement 9
  • 10. Creating Table Syntax CREATE TABLE table_name (column1 datatype null/not null, column2 datatype null/not null, …) Each column must have a datatype. The column should either be defined as "null" or "not null" and if this value is left blank, the database assumes "null" as the default 10
  • 11. Creating Table Specification ➔ NULL ➔ NOT NULL ➔ NOT NULL WITH DEFAULT When creating a table,one of these attributes is specified for a column NULL v/s NOT NULL ➔ NULL - Can be interpreted as unknown or not available Null doesn’t mean empty (blank) or 0 (Zero) ➔ NOT NULL - The user must provide values while inserting a row (0 or blank is allowed for these columns) 11
  • 12. Creating Table NOT NULL WITH DEFAULT The default value is stored,when a row is inserted without a specified value for this column. The default value is Zero (0) for numeric data fields Blank [empty] for character data fields Current date for DATE fields 12
  • 13. Data Types Common Data Types in MySQL char varchar text bigint binary blob bit int date datetime decimal enum float numeric ntext nvarchar nchar real double mediumtext smallinttimestamp datetime(x) time tinyintjson 13
  • 14. Integrity Constraints Primary Key Foreign Key Unique Key NOT NULL Check 14
  • 15. Integrity Constraints Primary Key ➔ A primary key is a single field or combination of fields that uniquely defines a record ➔ A table can have only one primary key ➔ A primary key can be defined in either a CREATE TABLE statement or an ALTER TABLE statement 15
  • 16. Integrity Constraints Foreign Key ➔ A foreign key means that values in one table must also appear in another table ➔ The foreign key in the child table will generally reference a primary key in the parent table ➔ A foreign key can be defined in either a CREATE TABLE statement or an ALTER TABLE statement 16
  • 17. Integrity Constraints Unique Key ➔ A unique constraint is a single field or combination of fields that uniquely defines a record. ➔ Some of the fields can contain null values as long as the combination of values is unique. ➔ A unique constraint can be defined in either a CREATE TABLE statement or an ALTER TABLE statement 17
  • 18. Integrity Constraints What is the difference between Primary Key and Unique Key? 18 Primary Key Unique Constraint None of the fields that are part of the primary key can contain a null value Some of the fields that are part of the unique constraint can contain null values as long as the combination of values is unique
  • 19. Integrity Constraints NOT NULL ➔ NOT NULL constraints are in-line constraints that indicate that a column can not contain NULL values CHECK ➔ Check constraints validate that values in a given column meet a specific criteria 19
  • 20. IDE/Tools MySQL Server Tools ➔ Toad for MySQL ➔ SQL Yog ➔ phpMyAdmin ➔ MySQL Administrator ➔ MySQL Query Browser ➔ MySQL WorkBench 20
  • 21. Structure of SQL Queries SELECT - column names / arithmetic expressions / literals / scalar functions / column functions FROM - table names or view names WHERE - conditions GROUP BY - column names HAVING - conditions ORDER BY - column names 21
  • 22. Table Aliases Table Alias ➔ The use of table aliases means to rename a table in a particular SQL statement ➔ The renaming is a temporary change ➔ The actual table name does not change in the database 22
  • 23. Comparison Operators In the WHERE clause ➔ Equal = ➔ Not Equal != or <> ➔ Less < ➔ Less or Equal < = ➔ Greater > ➔ Greater or Equal > = 23
  • 25. Additional Operators Additional Operators ➔ IN ➔ NOT IN ➔ BETWEEN ➔ NOT BETWEEN ➔ LIKE ➔ NOT LIKE ➔ IS NULL ➔ IS NOT NULL 25
  • 26. Distinct The DISTINCT clause ➔ Allows you to remove duplicates from the result set ➔ The DISTINCT clause can only be used with select statements. The syntax ➔ SELECT DISTINCT column_name FROM table_name 26
  • 27. Table Joins JOIN A join is used to combine rows from multiple tables Different types of joins ➔ INNER JOIN ➔ OUTER JOIN ➢ LEFT JOIN ➢ RIGHT JOIN ➢ FULL JOIN ➔ CARTESIAN JOIN 27
  • 28. WHERE Clause WHERE The WHERE clause allows you to filter the results from an SQL statement E.g. SELECT * FROM supplier WHERE supplier_name = ‘ABC’ 28
  • 29. GROUP Functions Group functions Return results based on groups of rows, rather than on single rows Main Group functions ➔ COUNT ➔ SUM ➔ MIN ➔ MAX ➔ AVG 29
  • 30. GROUP Functions COUNT function - returns the number of rows in a query SELECT COUNT(expression) FROM table_name; SUM Function - returns the summed value of an expression SELECT SUM(expression ) FROM table_name; MIN Function - returns the minimum value of an expression SELECT MIN(expression ) FROM table_name; MAX function - returns the maximum value of an expression SELECT MAX(expression ) FROM table_name; AVG Function - returns the average value of an expression SELECT AVG(expression) FROM table_name; 30
  • 31. Grouping GROUP BY Clause Can be used in a SELECT statement to collect data across multiple records and group the results by one or more columns The syntax SELECT column1,column2, aggregate_function(expression) FROM tables WHERE predicates GROUP BY column1, column2; 31
  • 32. Having Clause HAVING clause ➔ Used in combination with the GROUP BY clause. ➔ It can be used in a SELECT statement to filter the records that a GROUP BY returns. The syntax : SELECT column1, column2, ... column_n, aggregate_function (expression) FROM tables WHERE predicates GROUP BY column1, column2, ... column_n HAVING condition1 ... condition_n; 32
  • 33. ORDER BY Clause ORDER BY Allows to sort the records in your result set The ORDER BY clause can only be used in SELECT statements The syntax : SELECT columns FROM table WHERE predicate ORDER BY column ASC/DESC; ASC indicates ascending order. (default) DESC indicates descending order. 33
  • 34. UNION and UNION ALL UNION ➔ Allows to combine the result sets of 2 or more "select" queries ➔ It removes duplicate rows between the various "select" statements ➔ Each SQL statement within the UNION query must have the same number of fields in the result sets with similar data types The syntax : Select field1, field2, . field_n From tables UNION Select field1, field2, . field_n From tables; 34
  • 35. UNION and UNION ALL UNION ALL ➔ Allows to combine the result sets of 2 or more "select“ queries ➔ It returns all rows (even if the row exists in more than one of the "select" statements) ➔ Each SQL statement within the UNION ALL query must have the same number of fields in the result sets with similar data types The syntax : Select field1, field2, . field_n From tables UNION ALL Select field1, field2, . field_n From tables; 35
  • 36. Sub Query Subquery Is a query within a query [SELECT] Different Types ➔ Stand alone [independent existence] ➔ Co-related [dependent on outer select] 36
  • 37. INSERT, UPDATE and DELETE INSERT - Allows to insert a single record or multiple records into a table. INSERT INTO table (column-1, column-2, ... column-n) VALUES (value-1, value-2, ... value-n); UPDATE - Allows to update a single record or multiple records in a table. UPDATE table SET column = expression WHERE predicate; DELETE - Allows to delete a single record or multiple records from a table. DELETE FROM table WHERE predicate; Note : “i-am-a-dummy” configuration 37
  • 38. Database Design-Thump Rule A table generally should have an identifier. A table should store only data for a single type of entity. A table should avoid nullable columns. Table should not have repeating values or columns. Keep columns as short as possible. e.g. Use int for bigint 38
  • 41. Normalization Normalizing a logical database design involves using formal methods to separate the data into multiple, related tables A greater number of narrow tables (with fewer columns) is characteristic of a normalized database 41
  • 42. Benefits of Normalization Faster sorting and index creation. A larger number of clustered indexes. Narrower and more compact indexes. Fewer indexes per table, which improves the performance of INSERT, UPDATE, and DELETE statements. Fewer null values and less opportunity for inconsistency, which increase database compactness. 42
  • 43. INDEX As the name indicates, indexes are used to speed up the SELECT queries. Types : ➔ Clustered : Created by default when a primary key is created on the table. ➔ Non Clustered [Secondary] : All indexes other than the clustered index are known as secondary indexes. ● Restrictions : ✔ A table can contain a maximum of 64 secondary indexes. ✔ A maximum of 16 columns only permitted for multicolumn indexes. 43
  • 44. INDEX Disadvantages : ✔ The index slows down the speed of writing queries, such as INSERT, UPDATE and DELETE. So more number of indexes will lead to sluggishness of write operations. ✔ when we create index, it takes up disk space. the index file would grow much more quickly than the data file. 44
  • 45. Performance Tuning EXPLAIN EXTENDED SELECT * FROM stray_intakes WHERE nid = 1209159 AND gid = 464; table ➔ The table to which the row of output refers. 45
  • 46. Performance Tuning type The join type. Possible join types are listed below, ranked fastest to slowest: ➔ system - The table is a system table with only one row. ➔ const - The table has at most one matching row. A const query is fast because the table is read only once. ➔ eq_ref - No more than one row will be read from this table. This type is used when all columns of an index are used in the query, and the index is UNIQUE or a PRIMARY KEY. ➔ ref - All matching rows will be read from this table. This is used when an index is neither UNIQUE nor a PRIMARY. 46
  • 47. Performance Tuning ➔ range - Only rows in a given range will be retrieved from this table, using an index to select the rows. ➔ index - A full scan of the index will be performed for each combination of rows from previous tables. This is the same as an ALL join type except only the index is scanned. ➔ ALL - A full scan of the table will be performed for each combination of rows from previous tables. ALL joins should be avoided by adding an index. 47
  • 48. Performance Tuning possible_keys Lists which indexes MySQL could use to find the rows in this table. When there are no relevant indexes, possible_keys is NULL. This indicates that you can improve the performance of your query by adding an index. key Lists the actual index that MySQL chose. It is NULL if no index was chosen. rows Lists the number of rows that MySQL needs to examine from the table to execute the query. 48
  • 49. Advanced Concepts Information_Schema MySQL Engines Stored Procedures, Functions, Views Backup and Restore of Databases MySQL Replication MySQL Cluster 49
  • 50. 50 Thanks a lot for your time… Questions?