SlideShare a Scribd company logo
MySQL
BITM 3730
Developing Web Applications
Previous Work Review
• http://pirate.shu.edu/~marinom6/work.html
• Please Note only previously due HW assignments are posted on my
pirate.shu.edu web space
• Begin organizing your creating files for this course into an easy to find folder
on your desktop for easy FTP later on
Basics
• A new database is created using the code create database databasename
• Select is the function which allows you to choose something in MySQL
• The where function is also needed when using the select function to see where your
request is
• The from function relates to the select and where function; often seen formatted
using select from and where in that order – in order to select something from a
specific database in the section it is in
• Join type is based on join condition
Creating Contact Table with SQL Code
CREATE TABLE CONTACT
(
contact_id INT not null PRIMARY KEY
GENERATED ALWAYS AS IDENTITY
(START WITH 1, INCREMENT BY 1),
"FIRST_NAME" varchar(30),
"LAST_NAME" varchar(30),
"ADDRESS" varchar(30),
"CITY" varchar(30),
"STATE" varchar(30),
"ZIPCODE" varchar(30)
);
Select – From - Where
Select – From – Where Conditions
• Logical comparison operators
• =, <, <=, >, >=, and <>
• Projection attributes
• Attributes whose values are to be retrieved
• Selection condition
• Boolean condition that must be true for any retrieved tuple. Selection
conditions include join conditions (see Ch.8) when multiple relations are
involved.
Example
INSERT, DELETE, and UPDATE
• Three commands used to modify the database:
• INSERT, DELETE, and UPDATE
• INSERT typically inserts a tuple (row) in a relation (table)
• UPDATE may update a number of tuples (rows) in a relation (table) that
satisfy the condition
• DELETE may also update a number of tuples (rows) in a relation (table)
that satisfy the condition
Aggregate Functions in SQL
• Used to summarize information from multiple tuples into a single-tuple summary
• Built-in aggregate functions
• COUNT, SUM, MAX, MIN, and AVG
• Grouping
• Create subgroups of tuples before summarizing
• To select entire groups, HAVING clause is used
• Aggregate functions can be used in the SELECT clause or in a HAVING clause
Assertions and Triggers
• CREATE ASSERTION
• Specify additional types of constraints outside scope of built-in relational model
constraints
• CREATE TRIGGER
• Specify automatic actions that database system will perform when certain events and
conditions occur
Assertion Visual
Trigger Visual
R5:
CREATE TRIGGER SALARY_VIOLATION
BEFORE INSERT OR UPDATE OF Salary, Supervisor_ssn ON EMPLOYEE
FOR EACH ROW
WHEN (NEW.SALARY > ( SELECT Salary FROM EMPLOYEE
WHERE Ssn = NEW. Supervisor_Ssn))
INFORM_SUPERVISOR (NEW.Supervisor.Ssn, New.Ssn)
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 /*.
Querying
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;
Joins
• 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.
Joins Visual
Building Assignment 15
• 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;
Building Final Project
• Homepage – similar to http://pirate.shu.edu/~marinom6/ but list
information about yourself
• My Work – should look like http://pirate.shu.edu/~marinom6/work.html but
with your work linked, not mine
• Contact – should look like http://pirate.shu.edu/~marinom6/contact.html but
you can add your name or other info to the header if you want
• You might want to use your .css file to set text color and background color [or
feel free to use CSS embedded in your web pages
Extra Credit
• If you would like to complete the Extra Credit with the
additional form
• Reach out to me directly for assistance – not everyone
may want to do this

More Related Content

PPT
Mysql classes in navi-mumbai,mysql course-provider-in-navi-mumbai
PDF
Database management system important topic.pdf
PPT
Tutorial on MySQl and its basic concepts
PDF
MySQL 指南
PPT
mysql_tutorial dan penjelasan rinci .ppt
PPT
My sql advacnce topics
PPTX
Advance SQL.pptx
PPT
Mysql tutorial
Mysql classes in navi-mumbai,mysql course-provider-in-navi-mumbai
Database management system important topic.pdf
Tutorial on MySQl and its basic concepts
MySQL 指南
mysql_tutorial dan penjelasan rinci .ppt
My sql advacnce topics
Advance SQL.pptx
Mysql tutorial

Similar to BITM3730Week15.pptx (20)

PPT
Mysql tutorial
PPT
Mysql tutorial
PPTX
3-Chapter-Edit.pptx debre tabour university
PPT
Lect_04b_PhpMysqlKEY PERFORMANCE INDICATOR FOR ICT-UNIT (new).ppt
PDF
Introduction to SQLite in Adobe AIR
PDF
Power Automate Techniques that "Save
PPTX
SFDC Inbound Integrations
PPT
Data Warehouse , Data Cube Computation
PPTX
Introduction to PostgreSQL
PPTX
SQL.pptx for the begineers and good know
PPTX
PHP FUNCTIONS
PPTX
SQL - Structured query language introduction
PPTX
Introduction to Angular JS
PPTX
BITM3730Week14.pptx
PPT
MySQLi - An Improved Extension of MySQL
PPT
resource governor
PDF
Java OOP Programming language (Part 8) - Java Database JDBC
PPTX
Using AWS CloudWatch Custom Metrics and EC2 Auto Scaling -VSocial Infrastructure
PPT
INTRODUCTION TO SQL QUERIES REALTED BRIEF
PPTX
introductionofssis-130418034853-phpapp01.pptx
Mysql tutorial
Mysql tutorial
3-Chapter-Edit.pptx debre tabour university
Lect_04b_PhpMysqlKEY PERFORMANCE INDICATOR FOR ICT-UNIT (new).ppt
Introduction to SQLite in Adobe AIR
Power Automate Techniques that "Save
SFDC Inbound Integrations
Data Warehouse , Data Cube Computation
Introduction to PostgreSQL
SQL.pptx for the begineers and good know
PHP FUNCTIONS
SQL - Structured query language introduction
Introduction to Angular JS
BITM3730Week14.pptx
MySQLi - An Improved Extension of MySQL
resource governor
Java OOP Programming language (Part 8) - Java Database JDBC
Using AWS CloudWatch Custom Metrics and EC2 Auto Scaling -VSocial Infrastructure
INTRODUCTION TO SQL QUERIES REALTED BRIEF
introductionofssis-130418034853-phpapp01.pptx

More from MattMarino13 (20)

PPTX
INFO 2106 2-17-25.pptx Course Slide Deck
PPTX
INFO 2105 PPTs Fall 2024 ---------------
PPTX
1-22-24 INFO 2106.pptx
PPTX
1-24-24 INFO 3205.pptx
PPTX
BITM3730 11-14.pptx
PPTX
01_Felke-Morris_Lecture_ppt_ch01.pptx
PPTX
02slide_accessible.pptx
PPTX
Hoisington_Android_4e_PPT_CH01.pptx
PPTX
AndroidHTP3_AppA.pptx
PPTX
9780357132302_Langley11e_ch1_LEAP.pptx
PPTX
krajewski_om12 _01.pptx
PPTX
CapsimOpsIntroPPT.Marino.pptx
PPTX
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptx
PPTX
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptx
PPTX
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...
PPTX
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...
PPTX
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...
PPTX
1-23-19 Agenda.pptx
PPTX
EDF 8289 Marino PPT.pptx
PPTX
Agenda January 20th 2016.pptx
INFO 2106 2-17-25.pptx Course Slide Deck
INFO 2105 PPTs Fall 2024 ---------------
1-22-24 INFO 2106.pptx
1-24-24 INFO 3205.pptx
BITM3730 11-14.pptx
01_Felke-Morris_Lecture_ppt_ch01.pptx
02slide_accessible.pptx
Hoisington_Android_4e_PPT_CH01.pptx
AndroidHTP3_AppA.pptx
9780357132302_Langley11e_ch1_LEAP.pptx
krajewski_om12 _01.pptx
CapsimOpsIntroPPT.Marino.pptx
Project Presentation_castroxa_attempt_2021-12-05-18-30-10_No Cap.pptx
Project Presentation_mirzamad_attempt_2021-12-05-23-35-25_HTML_presentation.pptx
Project Presentation_padillni_attempt_2021-12-05-18-52-37_Web Application Pre...
Project Presentation_thomasb1_attempt_2021-12-05-17-50-13_Developing Web Apps...
Project Presentation_hernana1_attempt_2021-12-05-22-06-56_Miyamoto BITM 3730 ...
1-23-19 Agenda.pptx
EDF 8289 Marino PPT.pptx
Agenda January 20th 2016.pptx

Recently uploaded (20)

PDF
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Onica Farming 24rsclub profitable farm business
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PDF
Cell Biology Basics: Cell Theory, Structure, Types, and Organelles | BS Level...
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
PPTX
Congenital Hypothyroidism pptx
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PDF
Sunset Boulevard Student Revision Booklet
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
PDF
Open folder Downloads.pdf yes yes ges yes
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
Open Quiz Monsoon Mind Game Final Set.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Onica Farming 24rsclub profitable farm business
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Cardiovascular Pharmacology for pharmacy students.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Week 4 Term 3 Study Techniques revisited.pptx
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Cell Biology Basics: Cell Theory, Structure, Types, and Organelles | BS Level...
Revamp in MTO Odoo 18 Inventory - Odoo Slides
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
Congenital Hypothyroidism pptx
NOI Hackathon - Summer Edition - GreenThumber.pptx
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
Sunset Boulevard Student Revision Booklet
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
Open folder Downloads.pdf yes yes ges yes
Open Quiz Monsoon Mind Game Prelims.pptx

BITM3730Week15.pptx

  • 2. Previous Work Review • http://pirate.shu.edu/~marinom6/work.html • Please Note only previously due HW assignments are posted on my pirate.shu.edu web space • Begin organizing your creating files for this course into an easy to find folder on your desktop for easy FTP later on
  • 3. Basics • A new database is created using the code create database databasename • Select is the function which allows you to choose something in MySQL • The where function is also needed when using the select function to see where your request is • The from function relates to the select and where function; often seen formatted using select from and where in that order – in order to select something from a specific database in the section it is in • Join type is based on join condition
  • 4. Creating Contact Table with SQL Code CREATE TABLE CONTACT ( contact_id INT not null PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), "FIRST_NAME" varchar(30), "LAST_NAME" varchar(30), "ADDRESS" varchar(30), "CITY" varchar(30), "STATE" varchar(30), "ZIPCODE" varchar(30) );
  • 5. Select – From - Where
  • 6. Select – From – Where Conditions • Logical comparison operators • =, <, <=, >, >=, and <> • Projection attributes • Attributes whose values are to be retrieved • Selection condition • Boolean condition that must be true for any retrieved tuple. Selection conditions include join conditions (see Ch.8) when multiple relations are involved.
  • 8. INSERT, DELETE, and UPDATE • Three commands used to modify the database: • INSERT, DELETE, and UPDATE • INSERT typically inserts a tuple (row) in a relation (table) • UPDATE may update a number of tuples (rows) in a relation (table) that satisfy the condition • DELETE may also update a number of tuples (rows) in a relation (table) that satisfy the condition
  • 9. Aggregate Functions in SQL • Used to summarize information from multiple tuples into a single-tuple summary • Built-in aggregate functions • COUNT, SUM, MAX, MIN, and AVG • Grouping • Create subgroups of tuples before summarizing • To select entire groups, HAVING clause is used • Aggregate functions can be used in the SELECT clause or in a HAVING clause
  • 10. Assertions and Triggers • CREATE ASSERTION • Specify additional types of constraints outside scope of built-in relational model constraints • CREATE TRIGGER • Specify automatic actions that database system will perform when certain events and conditions occur
  • 12. Trigger Visual R5: CREATE TRIGGER SALARY_VIOLATION BEFORE INSERT OR UPDATE OF Salary, Supervisor_ssn ON EMPLOYEE FOR EACH ROW WHEN (NEW.SALARY > ( SELECT Salary FROM EMPLOYEE WHERE Ssn = NEW. Supervisor_Ssn)) INFORM_SUPERVISOR (NEW.Supervisor.Ssn, New.Ssn)
  • 13. 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 /*.
  • 14. Querying 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;
  • 15. Joins • 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.
  • 17. Building Assignment 15 • 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;
  • 18. Building Final Project • Homepage – similar to http://pirate.shu.edu/~marinom6/ but list information about yourself • My Work – should look like http://pirate.shu.edu/~marinom6/work.html but with your work linked, not mine • Contact – should look like http://pirate.shu.edu/~marinom6/contact.html but you can add your name or other info to the header if you want • You might want to use your .css file to set text color and background color [or feel free to use CSS embedded in your web pages
  • 19. Extra Credit • If you would like to complete the Extra Credit with the additional form • Reach out to me directly for assistance – not everyone may want to do this