SlideShare a Scribd company logo
MySQL Tutorial
Introduction to Database
Introduction of MySQL
• MySQL is an SQL (Structured Query Language) based
relational database management system (DBMS)
• MySQL is compatible with standard SQL
• MySQL is frequently used by PHP and Perl
• Commercial version of MySQL is also provided (including
technical support)
Resource
• MySQL and GUI Client can be downloaded
from
http://dev.mysql.com/downloads/

• The SQL script for creating database ‘bank’
can be found at
– http://www.cs.kent.edu/~mabuata/DB10_lab/bank_db.sql
Command for accessing MySQL
• Access from DB server
>ssh dbdev.cs.kent.edu
Start MySQL
>mysql –u [username] –p
>Enter password:[password]

• From a departmental machine
>mysql -u [username] -h dbdev.cs.kent.edu –p
>Enter password:[password]
Entering & Editing commands
• Prompt mysql>
– issue a command
– Mysql sends it to the server for execution
– displays the results
– prints another mysql>

• a command could span multiple lines
• A command normally consists of SQL
statement followed by a semicolon
Command prompt
prompt

meaning

mysql>

Ready for new command.

->

Waiting for next line of multiple-line command.

‘>

Waiting for next line, waiting for completion of a
string that began with a single quote (“'”).

“>

Waiting for next line, waiting for completion of a
string that began with a double quote (“"”).

`>

Waiting for next line, waiting for completion of an
identifier that began with a backtick (“`”).

/*>

Waiting for next line, waiting for completion of a
comment that began with /*.
MySQL commands
•
•
•
•
•

help h
Quit/exit q
Cancel the command c
Change database use
…etc
Info about databases and tables
• Listing the databases on the MySQL server host
– >show databases;

• Access/change database
– >Use [database_name]

• Showing the current selected database
– > select database();

• Showing tables in the current database
– >show tables;

• Showing the structure of a table
– > describe [table_name];
Banking Example
branch (branch-name, branch-city, assets)
customer (customer-name, customer-street, customer-city)
account (account-number, branch-name, balance)
loan (loan-number, branch-name, amount)
depositor (customer-name, account-number)
borrower (customer-name, loan-number)
employee (employee-name, branch-name, salary)
CREATE DATABASE
• An SQL relation is defined using the CREATE DATABASE
command:
– create database [database name]

• Example
– create database mydatabase
SQL Script for creating tables
• The SQL script for creating database ‘bank’
can be found at
http://www.cs.kent.edu/~mabuata/DB10_lab/bank_db.sql
http://www.cs.kent.edu/~mabuata/DB10_lab/bank_data.sql

Notice: we do not have permission to create database,
so you have to type command “use [your_account]” to
work on your database.
Query
•

To find all loan number for loans made at the Perryridge branch with loan
amounts greater than $1100.
select loan_number from loan
where branch_name = ‘Perryridge’ and amount>1100;

•

Find the loan number of those loans with loan amounts between $1,000
and $1,500 (that is, ≥$1,000 and ≤$1,500)
select loan_number from loan
where amount between 1000 and 1500;
Query
Find the names of all branches that have greater assets than some branch located
in Brooklyn.
select distinct T.branch_name
from branch as T, branch as S
where T.assets > S.assets and S.branch_city = ‘Brooklyn’;
Find the customer names and their loan numbers for all customers having a loan
at some branch.
select customer_name, T.loan_number, S.amount
from borrower as T, loan as S
where T.loan_number = S.loan_number;
Set Operation
•

Find all customers who have a loan, an account, or both:
(select customer_name from depositor)
union
(select customer_name from borrower);

•

Find all customers who have an account but no loan.
(no minus operator provided in mysql)
select customer_name from depositor
where customer_name not in
(select customer_name from borrower);
Aggregate function
•

Find the number of depositors for each branch.
select branch_name, count (distinct customer_name)
from depositor, account
where depositor.account_number = account.account_number
group by branch_name;

•

Find the names of all branches where the average account balance is more than
$500.
select branch_name, avg (balance)
from account
group by branch_name
having avg(balance) > 500;
Nested Subqueries
•

Find all customers who have both an account and a loan at the bank.
select distinct customer_name
from borrower
where customer_name in
(select customer_name from depositor);

•

Find all customers who have a loan at the bank but do not have an
account at the bank
select distinct customer_name
from borrower
where customer_name not in
(select customer_name from depositor);
Nested Subquery
•

Find the names of all branches that have greater assets than all branches
located in Horseneck.
select branch_name
from branch
where assets > all
(select assets
from branch
where branch_city = ‘Horseneck’);
Create View (new feature in mysql 5.0)
•

A view consisting of branches and their customers
create view all_customer as
(select branch_name, customer_name
from depositor, account
where depositor.account_number = account.account_number)
union
(select branch_name, customer_name
from borrower, loan
where borrower.loan_number=loan.loan_number);
Joined Relations
•
•
•
•

Join operations take two relations and return as a result another relation.
These additional operations are typically used as subquery expressions in the
from clause
Join condition – defines which tuples in the two relations match, and what
attributes are present in the result of the join.
Join type – defines how tuples in each relation that do not match any tuple in
the other relation (based on the join condition) are treated.
Joined Relations – Datasets for Examples
•

Relation loan

Relation borrower

Note: borrower information missing for L-260 and loan
information missing for L-155
Joined Relations – Examples

• Select * from loan inner join borrower on
loan.loan-number = borrower.loan-number
loan-number

branch-name

amount

customer-name

loan-number

L-170

Downtown

3000

Jones

L-170

L-230

Redwood

4000

Smith

L-230
Example

Select * from loan left join borrower on
loan.loan-number = borrower.loan-number
loan-number

branch-name

amount

customer-name

loan-number

L-170

Downtown

3000

Jones

L-170

L-230

Redwood

4000

Smith

L-230

L-260

Perryridge

1700

null

null
Modification of Database
•

Increase all accounts with balances over $800 by 7%, all other accounts
receive 8%.
update account
set balance = balance ∗ 1.07
where balance > 800;
update account
set balance = balance ∗ 1.08
where balance ≤ 800;
Modification of Database
•

Increase all accounts with balances over $700 by 6%, all other accounts
receive 5%.
update account
set balance =case
when balance <= 700 then balance *1.05
else balance * 1.06
end;
Modification of Database
•

Delete the record of all accounts with balances below the average at the
bank.
delete from account
where balance < (select avg (balance) from account);

•

Add a new tuple to account
insert into account
values (‘A-9732’, ‘Perryridge’,1200);
Exercise

1.Create a database employee and create a
table employee in it and do insert delete
updating operation on data

More Related Content

Viewers also liked

sas-course-provider-navi-mumbai-sas-training-navi-mumbai-sas-classes-navi-mumbai
sas-course-provider-navi-mumbai-sas-training-navi-mumbai-sas-classes-navi-mumbaisas-course-provider-navi-mumbai-sas-training-navi-mumbai-sas-classes-navi-mumbai
sas-course-provider-navi-mumbai-sas-training-navi-mumbai-sas-classes-navi-mumbai
anshkhurana01
 
Activitats la població 11
Activitats la població 11Activitats la població 11
Activitats la població 11llulsil23
 
Capital steel buildings business opportunities-uk
Capital steel buildings  business opportunities-ukCapital steel buildings  business opportunities-uk
Capital steel buildings business opportunities-ukRehmat Ullah
 
02 estimación del periodo de la estructura15 o
02 estimación del periodo de la estructura15 o02 estimación del periodo de la estructura15 o
02 estimación del periodo de la estructura15 o
Sarai Balbuena Martinez
 
CARTRIDGE SEAL INSTALLATION
CARTRIDGE SEAL INSTALLATIONCARTRIDGE SEAL INSTALLATION
CARTRIDGE SEAL INSTALLATION
American Seal and Packing
 
BJ Dooley's IT Toons COMICBOOK
BJ Dooley's IT Toons COMICBOOKBJ Dooley's IT Toons COMICBOOK
BJ Dooley's IT Toons COMICBOOK
Brian Dooley
 
Double cartridge seal
Double cartridge sealDouble cartridge seal
Double cartridge seal
American Seal and Packing
 
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbaiSiebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
anshkhurana01
 
Embeddedsystem training-course-navi-mumbai-embeddedsysteml-course-provider-na...
Embeddedsystem training-course-navi-mumbai-embeddedsysteml-course-provider-na...Embeddedsystem training-course-navi-mumbai-embeddedsysteml-course-provider-na...
Embeddedsystem training-course-navi-mumbai-embeddedsysteml-course-provider-na...
anshkhurana01
 

Viewers also liked (11)

sas-course-provider-navi-mumbai-sas-training-navi-mumbai-sas-classes-navi-mumbai
sas-course-provider-navi-mumbai-sas-training-navi-mumbai-sas-classes-navi-mumbaisas-course-provider-navi-mumbai-sas-training-navi-mumbai-sas-classes-navi-mumbai
sas-course-provider-navi-mumbai-sas-training-navi-mumbai-sas-classes-navi-mumbai
 
Activitats la població 11
Activitats la població 11Activitats la població 11
Activitats la població 11
 
Tâche 2
Tâche 2Tâche 2
Tâche 2
 
Capital steel buildings business opportunities-uk
Capital steel buildings  business opportunities-ukCapital steel buildings  business opportunities-uk
Capital steel buildings business opportunities-uk
 
02 estimación del periodo de la estructura15 o
02 estimación del periodo de la estructura15 o02 estimación del periodo de la estructura15 o
02 estimación del periodo de la estructura15 o
 
CARTRIDGE SEAL INSTALLATION
CARTRIDGE SEAL INSTALLATIONCARTRIDGE SEAL INSTALLATION
CARTRIDGE SEAL INSTALLATION
 
BJ Dooley's IT Toons COMICBOOK
BJ Dooley's IT Toons COMICBOOKBJ Dooley's IT Toons COMICBOOK
BJ Dooley's IT Toons COMICBOOK
 
Double cartridge seal
Double cartridge sealDouble cartridge seal
Double cartridge seal
 
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbaiSiebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
 
Embeddedsystem training-course-navi-mumbai-embeddedsysteml-course-provider-na...
Embeddedsystem training-course-navi-mumbai-embeddedsysteml-course-provider-na...Embeddedsystem training-course-navi-mumbai-embeddedsysteml-course-provider-na...
Embeddedsystem training-course-navi-mumbai-embeddedsysteml-course-provider-na...
 
Tangenta
TangentaTangenta
Tangenta
 

Similar to Mysql classes in navi-mumbai,mysql course-provider-in-navi-mumbai

MySQL 指南
MySQL 指南MySQL 指南
MySQL 指南
YUCHENG HU
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
santosh mishra
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
Smriti Jain
 
BITM3730Week15.pptx
BITM3730Week15.pptxBITM3730Week15.pptx
BITM3730Week15.pptx
MattMarino13
 
Data Warehouse , Data Cube Computation
Data Warehouse   , Data Cube ComputationData Warehouse   , Data Cube Computation
Data Warehouse , Data Cube Computation
sit20ad004
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data Model
Smriti Jain
 
Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01
Ankit Dubey
 
Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01
Ankit Dubey
 
Assignment#04
Assignment#04Assignment#04
Assignment#04
Sunita Milind Dol
 
5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMSkoolkampus
 
Marcus Matthews
Marcus MatthewsMarcus Matthews
Marcus Matthews
MarcusMatthews38
 
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdfDBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
AbhishekKumarPandit5
 
Assignment#09
Assignment#09Assignment#09
Assignment#09
Sunita Milind Dol
 
MySQLi - An Improved Extension of MySQL
MySQLi - An Improved Extension of MySQLMySQLi - An Improved Extension of MySQL
MySQLi - An Improved Extension of MySQL
Global Codester
 
Sql server select queries ppt 18
Sql server select queries ppt 18Sql server select queries ppt 18
Sql server select queries ppt 18
Vibrant Technologies & Computers
 
MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.
MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.
MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.
Prabhu Raja Singh
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Zeeshan Ahmed
 
dbms first unit
dbms first unitdbms first unit
dbms first unit
Raghu Bright
 

Similar to Mysql classes in navi-mumbai,mysql course-provider-in-navi-mumbai (20)

MySQL 指南
MySQL 指南MySQL 指南
MySQL 指南
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
BITM3730Week15.pptx
BITM3730Week15.pptxBITM3730Week15.pptx
BITM3730Week15.pptx
 
Data Warehouse , Data Cube Computation
Data Warehouse   , Data Cube ComputationData Warehouse   , Data Cube Computation
Data Warehouse , Data Cube Computation
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data Model
 
Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01
 
Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01Sm relationaldatamodel-150423084157-conversion-gate01
Sm relationaldatamodel-150423084157-conversion-gate01
 
Assignment#04
Assignment#04Assignment#04
Assignment#04
 
5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS
 
Marcus Matthews
Marcus MatthewsMarcus Matthews
Marcus Matthews
 
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdfDBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
 
Assignment#09
Assignment#09Assignment#09
Assignment#09
 
MySQLi - An Improved Extension of MySQL
MySQLi - An Improved Extension of MySQLMySQLi - An Improved Extension of MySQL
MySQLi - An Improved Extension of MySQL
 
Sql server select queries ppt 18
Sql server select queries ppt 18Sql server select queries ppt 18
Sql server select queries ppt 18
 
MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.
MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.
MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
dbms first unit
dbms first unitdbms first unit
dbms first unit
 

More from anshkhurana01

Aix admin-course-provider-navi-mumbai
Aix admin-course-provider-navi-mumbaiAix admin-course-provider-navi-mumbai
Aix admin-course-provider-navi-mumbai
anshkhurana01
 
Websphere application-server-training-course-navi-mumbai-websphere-applicatio...
Websphere application-server-training-course-navi-mumbai-websphere-applicatio...Websphere application-server-training-course-navi-mumbai-websphere-applicatio...
Websphere application-server-training-course-navi-mumbai-websphere-applicatio...
anshkhurana01
 
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...
anshkhurana01
 
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbai
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbaiLinux training-course-navi-mumbai-linux-course-provider-navi-mumbai
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbaianshkhurana01
 
Aix admin-course-provider-navi-mumbai
Aix admin-course-provider-navi-mumbaiAix admin-course-provider-navi-mumbai
Aix admin-course-provider-navi-mumbai
anshkhurana01
 
Java j2ee-training-course-navi-mumbai-java-j2ee-course-provider-navi-mumbai
Java j2ee-training-course-navi-mumbai-java-j2ee-course-provider-navi-mumbaiJava j2ee-training-course-navi-mumbai-java-j2ee-course-provider-navi-mumbai
Java j2ee-training-course-navi-mumbai-java-j2ee-course-provider-navi-mumbai
anshkhurana01
 
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbaiSiebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
anshkhurana01
 
Tibco training-course-navi-mumbai-tibco-course-provider-navi-mumbai
Tibco training-course-navi-mumbai-tibco-course-provider-navi-mumbaiTibco training-course-navi-mumbai-tibco-course-provider-navi-mumbai
Tibco training-course-navi-mumbai-tibco-course-provider-navi-mumbai
anshkhurana01
 
Mainframe training-course-navi-mumbai-mainframe-course-provider-navi-mumbai
Mainframe training-course-navi-mumbai-mainframe-course-provider-navi-mumbaiMainframe training-course-navi-mumbai-mainframe-course-provider-navi-mumbai
Mainframe training-course-navi-mumbai-mainframe-course-provider-navi-mumbai
anshkhurana01
 
Sas training-course-navi-mumbai-sas-course-provider-navi-mumbai
Sas training-course-navi-mumbai-sas-course-provider-navi-mumbaiSas training-course-navi-mumbai-sas-course-provider-navi-mumbai
Sas training-course-navi-mumbai-sas-course-provider-navi-mumbai
anshkhurana01
 
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbai
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbaiLinux training-course-navi-mumbai-linux-course-provider-navi-mumbai
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbai
anshkhurana01
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
anshkhurana01
 
Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...
Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...
Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...
anshkhurana01
 
Best java courses in navi mumbai best classes for java in navi mumbai-java cl...
Best java courses in navi mumbai best classes for java in navi mumbai-java cl...Best java courses in navi mumbai best classes for java in navi mumbai-java cl...
Best java courses in navi mumbai best classes for java in navi mumbai-java cl...
anshkhurana01
 

More from anshkhurana01 (16)

05php
05php05php
05php
 
Sajid
SajidSajid
Sajid
 
Aix admin-course-provider-navi-mumbai
Aix admin-course-provider-navi-mumbaiAix admin-course-provider-navi-mumbai
Aix admin-course-provider-navi-mumbai
 
Websphere application-server-training-course-navi-mumbai-websphere-applicatio...
Websphere application-server-training-course-navi-mumbai-websphere-applicatio...Websphere application-server-training-course-navi-mumbai-websphere-applicatio...
Websphere application-server-training-course-navi-mumbai-websphere-applicatio...
 
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...
Shell scripting-training-course-navi-mumbai-shell-scripting-course-provider-n...
 
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbai
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbaiLinux training-course-navi-mumbai-linux-course-provider-navi-mumbai
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbai
 
Aix admin-course-provider-navi-mumbai
Aix admin-course-provider-navi-mumbaiAix admin-course-provider-navi-mumbai
Aix admin-course-provider-navi-mumbai
 
Java j2ee-training-course-navi-mumbai-java-j2ee-course-provider-navi-mumbai
Java j2ee-training-course-navi-mumbai-java-j2ee-course-provider-navi-mumbaiJava j2ee-training-course-navi-mumbai-java-j2ee-course-provider-navi-mumbai
Java j2ee-training-course-navi-mumbai-java-j2ee-course-provider-navi-mumbai
 
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbaiSiebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
Siebel training-course-navi-mumbai-siebel-course-provider-navi-mumbai
 
Tibco training-course-navi-mumbai-tibco-course-provider-navi-mumbai
Tibco training-course-navi-mumbai-tibco-course-provider-navi-mumbaiTibco training-course-navi-mumbai-tibco-course-provider-navi-mumbai
Tibco training-course-navi-mumbai-tibco-course-provider-navi-mumbai
 
Mainframe training-course-navi-mumbai-mainframe-course-provider-navi-mumbai
Mainframe training-course-navi-mumbai-mainframe-course-provider-navi-mumbaiMainframe training-course-navi-mumbai-mainframe-course-provider-navi-mumbai
Mainframe training-course-navi-mumbai-mainframe-course-provider-navi-mumbai
 
Sas training-course-navi-mumbai-sas-course-provider-navi-mumbai
Sas training-course-navi-mumbai-sas-course-provider-navi-mumbaiSas training-course-navi-mumbai-sas-course-provider-navi-mumbai
Sas training-course-navi-mumbai-sas-course-provider-navi-mumbai
 
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbai
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbaiLinux training-course-navi-mumbai-linux-course-provider-navi-mumbai
Linux training-course-navi-mumbai-linux-course-provider-navi-mumbai
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
 
Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...
Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...
Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...
 
Best java courses in navi mumbai best classes for java in navi mumbai-java cl...
Best java courses in navi mumbai best classes for java in navi mumbai-java cl...Best java courses in navi mumbai best classes for java in navi mumbai-java cl...
Best java courses in navi mumbai best classes for java in navi mumbai-java cl...
 

Recently uploaded

Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 

Mysql classes in navi-mumbai,mysql course-provider-in-navi-mumbai

  • 2. Introduction of MySQL • MySQL is an SQL (Structured Query Language) based relational database management system (DBMS) • MySQL is compatible with standard SQL • MySQL is frequently used by PHP and Perl • Commercial version of MySQL is also provided (including technical support)
  • 3. Resource • MySQL and GUI Client can be downloaded from http://dev.mysql.com/downloads/ • The SQL script for creating database ‘bank’ can be found at – http://www.cs.kent.edu/~mabuata/DB10_lab/bank_db.sql
  • 4. Command for accessing MySQL • Access from DB server >ssh dbdev.cs.kent.edu Start MySQL >mysql –u [username] –p >Enter password:[password] • From a departmental machine >mysql -u [username] -h dbdev.cs.kent.edu –p >Enter password:[password]
  • 5. Entering & Editing commands • Prompt mysql> – issue a command – Mysql sends it to the server for execution – displays the results – prints another mysql> • a command could span multiple lines • A command normally consists of SQL statement followed by a semicolon
  • 6. Command prompt prompt meaning mysql> Ready for new command. -> Waiting for next line of multiple-line command. ‘> Waiting for next line, waiting for completion of a string that began with a single quote (“'”). “> Waiting for next line, waiting for completion of a string that began with a double quote (“"”). `> Waiting for next line, waiting for completion of an identifier that began with a backtick (“`”). /*> Waiting for next line, waiting for completion of a comment that began with /*.
  • 7. MySQL commands • • • • • help h Quit/exit q Cancel the command c Change database use …etc
  • 8. Info about databases and tables • Listing the databases on the MySQL server host – >show databases; • Access/change database – >Use [database_name] • Showing the current selected database – > select database(); • Showing tables in the current database – >show tables; • Showing the structure of a table – > describe [table_name];
  • 9. Banking Example branch (branch-name, branch-city, assets) customer (customer-name, customer-street, customer-city) account (account-number, branch-name, balance) loan (loan-number, branch-name, amount) depositor (customer-name, account-number) borrower (customer-name, loan-number) employee (employee-name, branch-name, salary)
  • 10. CREATE DATABASE • An SQL relation is defined using the CREATE DATABASE command: – create database [database name] • Example – create database mydatabase
  • 11. SQL Script for creating tables • The SQL script for creating database ‘bank’ can be found at http://www.cs.kent.edu/~mabuata/DB10_lab/bank_db.sql http://www.cs.kent.edu/~mabuata/DB10_lab/bank_data.sql Notice: we do not have permission to create database, so you have to type command “use [your_account]” to work on your database.
  • 12. Query • To find all loan number for loans made at the Perryridge branch with loan amounts greater than $1100. select loan_number from loan where branch_name = ‘Perryridge’ and amount>1100; • Find the loan number of those loans with loan amounts between $1,000 and $1,500 (that is, ≥$1,000 and ≤$1,500) select loan_number from loan where amount between 1000 and 1500;
  • 13. Query Find the names of all branches that have greater assets than some branch located in Brooklyn. select distinct T.branch_name from branch as T, branch as S where T.assets > S.assets and S.branch_city = ‘Brooklyn’; Find the customer names and their loan numbers for all customers having a loan at some branch. select customer_name, T.loan_number, S.amount from borrower as T, loan as S where T.loan_number = S.loan_number;
  • 14. Set Operation • Find all customers who have a loan, an account, or both: (select customer_name from depositor) union (select customer_name from borrower); • Find all customers who have an account but no loan. (no minus operator provided in mysql) select customer_name from depositor where customer_name not in (select customer_name from borrower);
  • 15. Aggregate function • Find the number of depositors for each branch. select branch_name, count (distinct customer_name) from depositor, account where depositor.account_number = account.account_number group by branch_name; • Find the names of all branches where the average account balance is more than $500. select branch_name, avg (balance) from account group by branch_name having avg(balance) > 500;
  • 16. Nested Subqueries • Find all customers who have both an account and a loan at the bank. select distinct customer_name from borrower where customer_name in (select customer_name from depositor); • Find all customers who have a loan at the bank but do not have an account at the bank select distinct customer_name from borrower where customer_name not in (select customer_name from depositor);
  • 17. Nested Subquery • Find the names of all branches that have greater assets than all branches located in Horseneck. select branch_name from branch where assets > all (select assets from branch where branch_city = ‘Horseneck’);
  • 18. Create View (new feature in mysql 5.0) • A view consisting of branches and their customers create view all_customer as (select branch_name, customer_name from depositor, account where depositor.account_number = account.account_number) union (select branch_name, customer_name from borrower, loan where borrower.loan_number=loan.loan_number);
  • 19. Joined Relations • • • • Join operations take two relations and return as a result another relation. These additional operations are typically used as subquery expressions in the from clause Join condition – defines which tuples in the two relations match, and what attributes are present in the result of the join. Join type – defines how tuples in each relation that do not match any tuple in the other relation (based on the join condition) are treated.
  • 20. Joined Relations – Datasets for Examples • Relation loan Relation borrower Note: borrower information missing for L-260 and loan information missing for L-155
  • 21. Joined Relations – Examples • Select * from loan inner join borrower on loan.loan-number = borrower.loan-number loan-number branch-name amount customer-name loan-number L-170 Downtown 3000 Jones L-170 L-230 Redwood 4000 Smith L-230
  • 22. Example Select * from loan left join borrower on loan.loan-number = borrower.loan-number loan-number branch-name amount customer-name loan-number L-170 Downtown 3000 Jones L-170 L-230 Redwood 4000 Smith L-230 L-260 Perryridge 1700 null null
  • 23. Modification of Database • Increase all accounts with balances over $800 by 7%, all other accounts receive 8%. update account set balance = balance ∗ 1.07 where balance > 800; update account set balance = balance ∗ 1.08 where balance ≤ 800;
  • 24. Modification of Database • Increase all accounts with balances over $700 by 6%, all other accounts receive 5%. update account set balance =case when balance <= 700 then balance *1.05 else balance * 1.06 end;
  • 25. Modification of Database • Delete the record of all accounts with balances below the average at the bank. delete from account where balance < (select avg (balance) from account); • Add a new tuple to account insert into account values (‘A-9732’, ‘Perryridge’,1200);
  • 26. Exercise 1.Create a database employee and create a table employee in it and do insert delete updating operation on data

Editor's Notes

  1. {}