SlideShare a Scribd company logo
STRUCTURED QUERY LANGUAGE (SQL)
FERRY KEMPERMAN
NANJING FOREIGN LANGUAGE SCHOOL
NOV 2019
CAN YOU TELL ME…….
✓ What the name is of this diagram?
✓ What the official name is for rectangles, lines and symbols used on the lines?
✓ What is the purpose of this diagram?
✓ Who designs this diagram in reality?
✓ In how many warehouses a specific product can be stored?
✓ How many orders a customer can actually place?
✓ If a customer calls with a complaint about an order, can you track the responsible sales rep?
✓ There is something wrong with this design. What? What would the solution be?
TODAY WE ARE GOING TO LEARN…..
➢How to ask questions and invoke tasks to the database using Structured Query Language
(SQL)
➢How to retrieve data from the database by writing a SELECT statement
➢How to manipulate data (add,modify,delete) using in a database using DML-statements
➢How to create a database and tables with keys using DDL-statements
DATABASE CLIENT / SERVER ARCHITECTURE
❑ Database servers are centralized in a LAN
❑ Clients send their request to the server
❑ Server responds by sending selected data
back to client
General procedure
1. Request: Sales rep wants a list of all orders of customer Xu
2. Database server (DBMS) receives request from client
3. Database server prioritizes, validates and queues request
4. Database server collects selected data from database
5. Database server sends selected data back to client
A request to the database is called a query.
The selected data returned to client is called a result set.
STRUCTURED QUERY LANGUAGE (SQL)
• SQL is the industry wide language in which queries to the database are written. It
was developed way back in the 1970-ies by IBM and adopted by the entire IT-
community.
• SQL is pronounced as Sequel, no S-Q-L
• SQL is a retrieval language, not a programming language!
• SQL has a fixed syntax, so it works on every database!
• SQL has three parts with different goals:
• SQL – DML : Part of the language that allows users to select and modify data
• SQL – DDL : Part of the language that allows designers to create/alter a database
and tables with keys
• SQL – DCL : Part of the language that allow DBA-ers to set permissions for users
to access certain parts of the database
LET’S WRITE A QUERY IN SQL!
A query to request data from a
database is called a SELECT
statement. A few examples…..
SELECT *
FROM tblCustomer
SELECT CustomerName, CustomerPhone
FROM tblCustomer
SELECT CustomerName
FROM tblCustomer
WHERE CustomerId = 24
Result set:
CustomerName
Brown
Result set:
CustomerID CustomerName CustomerPhone
23 Ronchi 987654
24 Brown 017288
25 William 837392
26 Dev 792749
Result set:
CustomerID CustomerName CustomerPhone
23 Ronchi 987654
24 Brown 017288
25 William 837392
26 Dev 792749
Break activity 1:
Design a query that shows all the products that were ordered.
✓ Discuss for 3 minutes with partner
✓ Write your query on the mini whiteboard
SELECT CustomerPhone
FROM tblCustomer
WHERE CustomerName = “William” OR CustomerName = “Ronchi”
ORDER BY CustomerPhone
Result set:
CustomerPhone
837392
987654
Is this result set useful for the end-user?
SELECT <attributes you want to see>
FROM <source tables>
WHERE <booleans to select records>
ORDER BY <attributes you want to sort by>
Break activity 2:
Design a query that lists only the productnames alphabetically that were
ordered by customer 23.
✓ Discuss for 3 minutes with partner
✓ Write your query on the mini whiteboard
BUT SOMETHING IS WRONG….
• List all the products ordered by
customer 23?
• Customer need to be referred to by
their name, not id!
• The request should be:
• List all products ordered by Customer
Ronchi!
• But….how to do this?
• CustomerName is not in the same table
as OrderDescription.
• This query wants to filter on
CustomerName, but wants to display
OrderDescription.
• This query requires two tables instead
of one!
• We use an INNER JOIN to do this.
SELECT O.OrderDesc
FROM tblCustomer C INNER JOIN tblOrder ON C.CustomerID=O.CustomerID
WHERE C.CustomerName = “Ronchi”
ORDER BY O.OrderDesc
Break activity 3:
Design a query that lists all the product descriptions alphabetically ordered
by customer William and Brown!
✓ Discuss for 3 minutes with partner
✓ Write your query on the mini whiteboard
DATA MANIPULATION LANGUAGE (DML)
• DML is part of SQL that include statements that can manipulate data:
• INSERT statement to insert new data into a table
• UPDATE statement to modify existing data in a table
• DELETE statement to delete existing record(s) from a table
INSERT INTO Customer (CustID,CustName,CustPhone) UPDATE Customer DELETE FROM Customer
VALUES (1,”Kemperman”,”0018013”), SET CustName = “Smith” WHERE CustName = ‘Smith’
(2,”Zhang”,”123483”) WHERE CustID = 1
DATA DEFINITION LANGUAGE (DDL)
• Data definition language (DDL) is a part of SQL that is used by database designers. With
DDL you can
• Create a database
• Create new tables in a database
• Alter a table in a database
• Dropping (deleting) tables in a database
• Add primary and foreign keys to tables
• Database users do NOT have the permissions to use DDL, only designers have.
• Why? Deleting a customer table by accident?  Really?!
• Database users need to able to access the DATA only, not the DATABASE itself!
DDL STATEMENTS, AN EXAMPLE.
BUSINESS CASE : WRITING QUERIES
• Sample database (ERD – Populated tables)
• Write 10 queries based on the sample database
• Groups 2 of two students. Choose yourself.
• Write a report with the queries in SQL.
• Business case published on Schoology.

More Related Content

Similar to Structured Query Language introduction..

1585625790_SQL-SESSION1.pptx
1585625790_SQL-SESSION1.pptx1585625790_SQL-SESSION1.pptx
1585625790_SQL-SESSION1.pptx
MullaMainuddin
 
SQL
SQLSQL
DBMS.pptx
DBMS.pptxDBMS.pptx
DBMS.pptx
UmmerFarooq23
 
SQL NAD DB.pptx
SQL NAD DB.pptxSQL NAD DB.pptx
SQL NAD DB.pptx
muhammadhumza26
 
SQL in the Hybrid World
SQL in the Hybrid WorldSQL in the Hybrid World
SQL in the Hybrid World
Tanel Poder
 
Database Management System - SQL beginner Training
Database Management System - SQL beginner Training Database Management System - SQL beginner Training
Database Management System - SQL beginner Training
Moutasm Tamimi
 
FOUNDATION OF DATA SCIENCE SQL QUESTIONS
FOUNDATION OF DATA SCIENCE SQL QUESTIONSFOUNDATION OF DATA SCIENCE SQL QUESTIONS
FOUNDATION OF DATA SCIENCE SQL QUESTIONS
HITIKAJAIN4
 
Unit - II.pptx
Unit - II.pptxUnit - II.pptx
Unit - II.pptx
MrsSavitaKumbhare
 
MS ACCESS.pptx
MS ACCESS.pptxMS ACCESS.pptx
MS ACCESS.pptx
MattMarino13
 
Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)
Guy Harrison
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
enosislearningcom
 
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...
Rohan Byanjankar
 
Tk2323 lecture 7 sql
Tk2323 lecture 7   sql Tk2323 lecture 7   sql
Tk2323 lecture 7 sql
MengChun Lam
 
intro for sql
intro for sql intro for sql
intro for sql
mahmoud mones
 
Introduction to CQL and Data Modeling with Apache Cassandra
Introduction to CQL and Data Modeling with Apache CassandraIntroduction to CQL and Data Modeling with Apache Cassandra
Introduction to CQL and Data Modeling with Apache Cassandra
Johnny Miller
 
Cassandra Basics, Counters and Time Series Modeling
Cassandra Basics, Counters and Time Series ModelingCassandra Basics, Counters and Time Series Modeling
Cassandra Basics, Counters and Time Series Modeling
Vassilis Bekiaris
 
How Clean is your Database? Data Scrubbing for all Skill Sets
How Clean is your Database? Data Scrubbing for all Skill SetsHow Clean is your Database? Data Scrubbing for all Skill Sets
How Clean is your Database? Data Scrubbing for all Skill Sets
Chad Petrovay
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
Vibrant Technologies & Computers
 
Unit4_Lecture-sql.ppt and data science relate
Unit4_Lecture-sql.ppt and data science relateUnit4_Lecture-sql.ppt and data science relate
Unit4_Lecture-sql.ppt and data science relate
umang2782love
 
SQL .pptx
SQL .pptxSQL .pptx

Similar to Structured Query Language introduction.. (20)

1585625790_SQL-SESSION1.pptx
1585625790_SQL-SESSION1.pptx1585625790_SQL-SESSION1.pptx
1585625790_SQL-SESSION1.pptx
 
SQL
SQLSQL
SQL
 
DBMS.pptx
DBMS.pptxDBMS.pptx
DBMS.pptx
 
SQL NAD DB.pptx
SQL NAD DB.pptxSQL NAD DB.pptx
SQL NAD DB.pptx
 
SQL in the Hybrid World
SQL in the Hybrid WorldSQL in the Hybrid World
SQL in the Hybrid World
 
Database Management System - SQL beginner Training
Database Management System - SQL beginner Training Database Management System - SQL beginner Training
Database Management System - SQL beginner Training
 
FOUNDATION OF DATA SCIENCE SQL QUESTIONS
FOUNDATION OF DATA SCIENCE SQL QUESTIONSFOUNDATION OF DATA SCIENCE SQL QUESTIONS
FOUNDATION OF DATA SCIENCE SQL QUESTIONS
 
Unit - II.pptx
Unit - II.pptxUnit - II.pptx
Unit - II.pptx
 
MS ACCESS.pptx
MS ACCESS.pptxMS ACCESS.pptx
MS ACCESS.pptx
 
Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
 
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...
Concept of Structured Query Language (SQL) in SQL server as well as MySql. BB...
 
Tk2323 lecture 7 sql
Tk2323 lecture 7   sql Tk2323 lecture 7   sql
Tk2323 lecture 7 sql
 
intro for sql
intro for sql intro for sql
intro for sql
 
Introduction to CQL and Data Modeling with Apache Cassandra
Introduction to CQL and Data Modeling with Apache CassandraIntroduction to CQL and Data Modeling with Apache Cassandra
Introduction to CQL and Data Modeling with Apache Cassandra
 
Cassandra Basics, Counters and Time Series Modeling
Cassandra Basics, Counters and Time Series ModelingCassandra Basics, Counters and Time Series Modeling
Cassandra Basics, Counters and Time Series Modeling
 
How Clean is your Database? Data Scrubbing for all Skill Sets
How Clean is your Database? Data Scrubbing for all Skill SetsHow Clean is your Database? Data Scrubbing for all Skill Sets
How Clean is your Database? Data Scrubbing for all Skill Sets
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
 
Unit4_Lecture-sql.ppt and data science relate
Unit4_Lecture-sql.ppt and data science relateUnit4_Lecture-sql.ppt and data science relate
Unit4_Lecture-sql.ppt and data science relate
 
SQL .pptx
SQL .pptxSQL .pptx
SQL .pptx
 

More from FerryKemperman

Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
FerryKemperman
 
Working with files (concepts/pseudocode/python)
Working with files (concepts/pseudocode/python)Working with files (concepts/pseudocode/python)
Working with files (concepts/pseudocode/python)
FerryKemperman
 
Top_down_programming..............................
Top_down_programming..............................Top_down_programming..............................
Top_down_programming..............................
FerryKemperman
 
OOP in Python, a beginners guide..........
OOP in Python, a beginners guide..........OOP in Python, a beginners guide..........
OOP in Python, a beginners guide..........
FerryKemperman
 
Search and Sort algorithms. Bubble, Insertion, Selection.
Search and Sort algorithms. Bubble, Insertion, Selection.Search and Sort algorithms. Bubble, Insertion, Selection.
Search and Sort algorithms. Bubble, Insertion, Selection.
FerryKemperman
 
SDT introduction as given at MKIS, KL, 2023
SDT introduction as given at MKIS, KL, 2023SDT introduction as given at MKIS, KL, 2023
SDT introduction as given at MKIS, KL, 2023
FerryKemperman
 
Computer Architecture Machine Cycle (1).pdf
Computer Architecture Machine Cycle (1).pdfComputer Architecture Machine Cycle (1).pdf
Computer Architecture Machine Cycle (1).pdf
FerryKemperman
 
Referential integrity in databases.pptx
Referential integrity in databases.pptxReferential integrity in databases.pptx
Referential integrity in databases.pptx
FerryKemperman
 

More from FerryKemperman (8)

Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Working with files (concepts/pseudocode/python)
Working with files (concepts/pseudocode/python)Working with files (concepts/pseudocode/python)
Working with files (concepts/pseudocode/python)
 
Top_down_programming..............................
Top_down_programming..............................Top_down_programming..............................
Top_down_programming..............................
 
OOP in Python, a beginners guide..........
OOP in Python, a beginners guide..........OOP in Python, a beginners guide..........
OOP in Python, a beginners guide..........
 
Search and Sort algorithms. Bubble, Insertion, Selection.
Search and Sort algorithms. Bubble, Insertion, Selection.Search and Sort algorithms. Bubble, Insertion, Selection.
Search and Sort algorithms. Bubble, Insertion, Selection.
 
SDT introduction as given at MKIS, KL, 2023
SDT introduction as given at MKIS, KL, 2023SDT introduction as given at MKIS, KL, 2023
SDT introduction as given at MKIS, KL, 2023
 
Computer Architecture Machine Cycle (1).pdf
Computer Architecture Machine Cycle (1).pdfComputer Architecture Machine Cycle (1).pdf
Computer Architecture Machine Cycle (1).pdf
 
Referential integrity in databases.pptx
Referential integrity in databases.pptxReferential integrity in databases.pptx
Referential integrity in databases.pptx
 

Recently uploaded

一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
ahzuo
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
nuttdpt
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
TravisMalana
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
dwreak4tg
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
jerlynmaetalle
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
nuttdpt
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
Social Samosa
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
slg6lamcq
 
My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.
rwarrenll
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
g4dpvqap0
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
v3tuleee
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
nyfuhyz
 
University of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma TranscriptUniversity of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma Transcript
soxrziqu
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
vikram sood
 
Unleashing the Power of Data_ Choosing a Trusted Analytics Platform.pdf
Unleashing the Power of Data_ Choosing a Trusted Analytics Platform.pdfUnleashing the Power of Data_ Choosing a Trusted Analytics Platform.pdf
Unleashing the Power of Data_ Choosing a Trusted Analytics Platform.pdf
Enterprise Wired
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
oz8q3jxlp
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
AndrzejJarynowski
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
74nqk8xf
 
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
u86oixdj
 

Recently uploaded (20)

一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
 
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
一比一原版(BCU毕业证书)伯明翰城市大学毕业证如何办理
 
Influence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business PlanInfluence of Marketing Strategy and Market Competition on Business Plan
Influence of Marketing Strategy and Market Competition on Business Plan
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
 
My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.My burning issue is homelessness K.C.M.O.
My burning issue is homelessness K.C.M.O.
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
 
University of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma TranscriptUniversity of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma Transcript
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
 
Unleashing the Power of Data_ Choosing a Trusted Analytics Platform.pdf
Unleashing the Power of Data_ Choosing a Trusted Analytics Platform.pdfUnleashing the Power of Data_ Choosing a Trusted Analytics Platform.pdf
Unleashing the Power of Data_ Choosing a Trusted Analytics Platform.pdf
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
 
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
 

Structured Query Language introduction..

  • 1. STRUCTURED QUERY LANGUAGE (SQL) FERRY KEMPERMAN NANJING FOREIGN LANGUAGE SCHOOL NOV 2019
  • 2. CAN YOU TELL ME……. ✓ What the name is of this diagram? ✓ What the official name is for rectangles, lines and symbols used on the lines? ✓ What is the purpose of this diagram? ✓ Who designs this diagram in reality? ✓ In how many warehouses a specific product can be stored? ✓ How many orders a customer can actually place? ✓ If a customer calls with a complaint about an order, can you track the responsible sales rep? ✓ There is something wrong with this design. What? What would the solution be?
  • 3. TODAY WE ARE GOING TO LEARN….. ➢How to ask questions and invoke tasks to the database using Structured Query Language (SQL) ➢How to retrieve data from the database by writing a SELECT statement ➢How to manipulate data (add,modify,delete) using in a database using DML-statements ➢How to create a database and tables with keys using DDL-statements
  • 4. DATABASE CLIENT / SERVER ARCHITECTURE ❑ Database servers are centralized in a LAN ❑ Clients send their request to the server ❑ Server responds by sending selected data back to client General procedure 1. Request: Sales rep wants a list of all orders of customer Xu 2. Database server (DBMS) receives request from client 3. Database server prioritizes, validates and queues request 4. Database server collects selected data from database 5. Database server sends selected data back to client A request to the database is called a query. The selected data returned to client is called a result set.
  • 5. STRUCTURED QUERY LANGUAGE (SQL) • SQL is the industry wide language in which queries to the database are written. It was developed way back in the 1970-ies by IBM and adopted by the entire IT- community. • SQL is pronounced as Sequel, no S-Q-L • SQL is a retrieval language, not a programming language! • SQL has a fixed syntax, so it works on every database! • SQL has three parts with different goals: • SQL – DML : Part of the language that allows users to select and modify data • SQL – DDL : Part of the language that allows designers to create/alter a database and tables with keys • SQL – DCL : Part of the language that allow DBA-ers to set permissions for users to access certain parts of the database
  • 6. LET’S WRITE A QUERY IN SQL! A query to request data from a database is called a SELECT statement. A few examples….. SELECT * FROM tblCustomer SELECT CustomerName, CustomerPhone FROM tblCustomer SELECT CustomerName FROM tblCustomer WHERE CustomerId = 24 Result set: CustomerName Brown Result set: CustomerID CustomerName CustomerPhone 23 Ronchi 987654 24 Brown 017288 25 William 837392 26 Dev 792749 Result set: CustomerID CustomerName CustomerPhone 23 Ronchi 987654 24 Brown 017288 25 William 837392 26 Dev 792749
  • 7. Break activity 1: Design a query that shows all the products that were ordered. ✓ Discuss for 3 minutes with partner ✓ Write your query on the mini whiteboard
  • 8. SELECT CustomerPhone FROM tblCustomer WHERE CustomerName = “William” OR CustomerName = “Ronchi” ORDER BY CustomerPhone Result set: CustomerPhone 837392 987654 Is this result set useful for the end-user? SELECT <attributes you want to see> FROM <source tables> WHERE <booleans to select records> ORDER BY <attributes you want to sort by>
  • 9. Break activity 2: Design a query that lists only the productnames alphabetically that were ordered by customer 23. ✓ Discuss for 3 minutes with partner ✓ Write your query on the mini whiteboard
  • 10. BUT SOMETHING IS WRONG…. • List all the products ordered by customer 23? • Customer need to be referred to by their name, not id! • The request should be: • List all products ordered by Customer Ronchi! • But….how to do this? • CustomerName is not in the same table as OrderDescription. • This query wants to filter on CustomerName, but wants to display OrderDescription. • This query requires two tables instead of one! • We use an INNER JOIN to do this. SELECT O.OrderDesc FROM tblCustomer C INNER JOIN tblOrder ON C.CustomerID=O.CustomerID WHERE C.CustomerName = “Ronchi” ORDER BY O.OrderDesc
  • 11. Break activity 3: Design a query that lists all the product descriptions alphabetically ordered by customer William and Brown! ✓ Discuss for 3 minutes with partner ✓ Write your query on the mini whiteboard
  • 12. DATA MANIPULATION LANGUAGE (DML) • DML is part of SQL that include statements that can manipulate data: • INSERT statement to insert new data into a table • UPDATE statement to modify existing data in a table • DELETE statement to delete existing record(s) from a table INSERT INTO Customer (CustID,CustName,CustPhone) UPDATE Customer DELETE FROM Customer VALUES (1,”Kemperman”,”0018013”), SET CustName = “Smith” WHERE CustName = ‘Smith’ (2,”Zhang”,”123483”) WHERE CustID = 1
  • 13. DATA DEFINITION LANGUAGE (DDL) • Data definition language (DDL) is a part of SQL that is used by database designers. With DDL you can • Create a database • Create new tables in a database • Alter a table in a database • Dropping (deleting) tables in a database • Add primary and foreign keys to tables • Database users do NOT have the permissions to use DDL, only designers have. • Why? Deleting a customer table by accident?  Really?! • Database users need to able to access the DATA only, not the DATABASE itself!
  • 14. DDL STATEMENTS, AN EXAMPLE.
  • 15. BUSINESS CASE : WRITING QUERIES • Sample database (ERD – Populated tables) • Write 10 queries based on the sample database • Groups 2 of two students. Choose yourself. • Write a report with the queries in SQL. • Business case published on Schoology.