SlideShare a Scribd company logo
J
j_num
jname
city
j1
Sorter
Paris
j2
Punch
Rome
j3
Reader
Athens
j4
Console
Athens
j5
Collator
London
j6
Terminal
Oslo
j7
Tape
London
P
p_num
pname
color
weight
city
p1
Nut
Red
12
London
p2
Bolt
Green
17
Paris
p3
Screw
Blue
17
Rome
p4
Screw
Red
14
London
p5
Cam
Blue
12
Paris
p6
Cog
Red
19
London
S
s_num
s_name
status
city
s1
Smith
20
London
s2
Jones
10
Paris
s3
Blake
30
Paris
s4
Clark
20
London
s5
Adams
30
Athens
SPJ
s_num
p_num
j_num
qty
s1
p1
j1
200
s1
p1
j4
700
s2
p3
j1
400
s2
p3
j2
200
s2
p3
j3
200
s2
p3
j4
500
s2
p3
j5
600
s2
p3
j6
400
s2
p3
j7
800
s2
p5
j2
100
s3
p3
j1
200
s3
p4
j2
500
s4
p6
j3
300
s4
p6
j7
300
s5
p1
j4
100
s5
p2
j2
200
s5
p2
j4
100
s5
p3
j4
200
s5
p4
j4
800
s5
p5
j4
400
s5
p5
j5
500
s5
p5
j7
100
s5
p6
j2
200
s5
p6
j4
500
Note: Qty, status, and weight are numbers.
Exercise
1. Get supplier names and numbers for all suppliers who supplied part P3 and whose name
begins with letter A.
2. Get supplier names and numbers for all suppliers whose name (supplier name) begins with
letter A and who supplied parts whose name (part’s name) begins with setter S.
3. Get supplier names for suppliers who supplied for job J2. (Use a sub query)
4. Get supplier names for suppliers who supplied parts for jobs only in Athens. (Use sub query)
5. Get part names for parts that are not supplied for job J3. (Use a sub query)
6. Get supplier numbers for suppliers with status lower than that of supplier S1.
7. Get supplier numbers and names for suppliers whose status is greater than status values of all
suppliers in located Paris.
8. Calculate each supplier’s total sales quantity and get the sales person’s name if the sales
person supplies parts more than 1000 units in total.
9. Get job numbers for jobs whose city is first in the alphabetical list of the job cities.
10. Increase the status values of suppliers by 5 who are located in Paris.
Please hand in the modified table and the query.
11. Change the name to ‘Hammer’ of parts that are Red and located in London and whose name
was Screw.
Please hand in the modified table and the query.
12. Delete all jobs in Rome and all corresponding part shipments. (Please use 2 queries)
Please hand in the modified table and the query.
13. Smith moved to Adam’s location. Please update Smith’s city but do not use the city name
directly.
14. Please create a “view table” supplier_shipment that shows each supplier and its total
shipment quantity. (if the system do not allow you to create a view table then skip this question)
15. Please try to increase Smith’s total shipment by 100 in the view table you created in question
14. Then discuss what happens when you try to update the view table. (if question 14 is
successful)
16. Please create a base table supplier_shipment that shows each supplier and its total shipments
from S and SPJ tables.
17. Please repeat question 15 on the base table supplier_shipment and discuss the result.
Note: You might need following setting before run your update SQL
SET SQL_SAFE_UPDATES = 0;
j_num
jname
city
j1
Sorter
Paris
j2
Punch
Rome
j3
Reader
Athens
j4
Console
Athens
j5
Collator
London
j6
Terminal
Oslo
j7
Tape
London
Solution
If you have any doubts, please give me comment...
-- 1. Get supplier names and numbers for all suppliers who supplied part P3 and whose name
begins with letter A.
SELECT s_name, s_num
FROM S INNER JOIN SPJ ON S.s_num = SPJ.s_num
WHERE s_name LIKE 'A%' AND p_num = P3;
-- 2. Get supplier names and numbers for all suppliers whose name (supplier name) begins with
letter A and who supplied parts whose name (part’s name) begins with setter S.
SELECT s_name, s_num
FROM (S INNER JOIN SPJ ON S.s_num = SPJ.s_num) INNER JOIN P ON SPJ.p_num =
P.p_num
WHERE s_name LIKE 'A%' AND pname = 'S%';
-- 3. Get supplier names for suppliers who supplied for job J2. (Use a sub query)
SELECT s_num
FROM S
WHERE s_num IN(
SELECT s_num
FROM SPJ
WHERE j_num = 'j2'
);
-- 4. Get supplier names for suppliers who supplied parts for jobs only in Athens. (Use sub
query)
SELECT s_num
FROM (S INNER JOIN SPJ ON S.s_num = SPJ.s_num) INNER JOIN J ON SPJ.j_num =
J.j_num
WHERE J.city = 'Athens' AND s_num NOT IN(
SELECT s_num
FROM (S INNER JOIN SPJ ON S.s_num = SPJ.s_num) INNER JOIN J ON SPJ.j_num =
J.j_num
WHERE J.city <> 'Athens'
);
-- 5. Get part names for parts that are not supplied for job J3. (Use a sub query)
SELECT pname
FROM P
WHERE p_num NOT IN(
SELECT p_num
FROM SPJ
WHERE p_num = 'j3'
);
-- 6. Get supplier numbers for suppliers with status lower than that of supplier S1.
SELECT s_num
FROM S
WHERE status < (
SELECT status
FROM S
WHERE s_num = 's1'
);
-- 7. Get supplier numbers and names for suppliers whose status is greater than status values of
all suppliers in located Paris.
SELECT s_num, sname
FROM S
WHERE status > ALL(
SELECT status
FROM S
WHERE city = Paris
);
-- 8. Calculate each supplier’s total sales quantity and get the sales person’s name if the sales
person supplies parts more than 1000 units in total.
SELECT S.s_num, s_name, SUM(qty)
FROM S INNER JOIN SPJ ON S.s_num = SPJ.s_num
GROUP BY S.s_num,s_name
HAVING SUM(qty)>1000;
-- 9. Get job numbers for jobs whose city is first in the alphabetical list of the job cities.
SELECT j_num
FROM J
WHERE j_num IN(
SELECT j_num
FROM J
ORDER BY city
LIMIT 1
);
-- 10. Increase the status values of suppliers by 5 who are located in Paris.
-- Please hand in the modified table and the query.
UPDATE S SET status = status+5 WHERE city ='Paris';
SELECT *
FROM S;
-- 11. Change the name to ‘Hammer’ of parts that are Red and located in London and whose
name was Screw.
-- Please hand in the modified table and the query.
UPDATE P SET pname = 'Hammer' WHERE color = 'Red' AND city ='London' AND
pname='Screw';
SELECT *
FROM P;
-- 12. Delete all jobs in Rome and all corresponding part shipments. (Please use 2 queries)
-- Please hand in the modified table and the query.
DELETE FROM SPJ WHERE j_num IN (
SELECT j_num
FROM J
WHERE city = 'Rome'
);
DELETE FROM J WHERE city ='Rome';
-- 13. Smith moved to Adam’s location. Please update Smith’s city but do not use the city name
directly.
UPDATE S SET city = (SELECT city FROM S WHERE s_name='Adams') WHERE
s_name='Smith';
-- 14. Please create a “view table” supplier_shipment that shows each supplier and its total
shipment quantity. (if the system do not allow you to create a view table then skip this question)
CREATE VIEW supplier_shipment AS
SELECT s_num, SUM(qty) AS qty
FROM SPJ
GROUP s_num;
-- 15. Please try to increase Smith’s total shipment by 100 in the view table you created in
question 14. Then discuss what happens when you try to update the view table. (if question 14 is
successful)
UPDATE supplier_shipment SET qty = qty +100;
-- 16. Please create a base table supplier_shipment that shows each supplier and its total
shipments from S and SPJ tables.
DESCRIBE supplier_shipment;

More Related Content

More from fatoryoutlets

the ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdfthe ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdf
fatoryoutlets
 
Template LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdfTemplate LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdf
fatoryoutlets
 
Surface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdfSurface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdf
fatoryoutlets
 
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdfSuppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
fatoryoutlets
 
Q1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdfQ1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdf
fatoryoutlets
 
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdfPrint Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
fatoryoutlets
 
Part A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdfPart A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdf
fatoryoutlets
 
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdfOnly 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
fatoryoutlets
 
Note Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdfNote Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdf
fatoryoutlets
 
Negotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdfNegotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdf
fatoryoutlets
 
9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf
fatoryoutlets
 
If law enforcement fails to give the defendant their Miranda rights,.pdf
If law enforcement fails to give the defendant their Miranda rights,.pdfIf law enforcement fails to give the defendant their Miranda rights,.pdf
If law enforcement fails to give the defendant their Miranda rights,.pdf
fatoryoutlets
 
Identify one cyberattack that occurred in the last 2 years. What cau.pdf
Identify one cyberattack that occurred in the last 2 years. What cau.pdfIdentify one cyberattack that occurred in the last 2 years. What cau.pdf
Identify one cyberattack that occurred in the last 2 years. What cau.pdf
fatoryoutlets
 
How do I add another txt.file to this Im trying to add this to be.pdf
How do I add another txt.file to this Im trying to add this to be.pdfHow do I add another txt.file to this Im trying to add this to be.pdf
How do I add another txt.file to this Im trying to add this to be.pdf
fatoryoutlets
 
How you will respond empathetically, ethically, and legally to famil.pdf
How you will respond empathetically, ethically, and legally to famil.pdfHow you will respond empathetically, ethically, and legally to famil.pdf
How you will respond empathetically, ethically, and legally to famil.pdf
fatoryoutlets
 
How can an insoluble salt with a basic anion be made to dissolve.pdf
How can an insoluble salt with a basic anion be made to dissolve.pdfHow can an insoluble salt with a basic anion be made to dissolve.pdf
How can an insoluble salt with a basic anion be made to dissolve.pdf
fatoryoutlets
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdf
fatoryoutlets
 
Describe the steps in Sanger DNA sequencing. Provide a high level des.pdf
Describe the steps in Sanger DNA sequencing. Provide a high level des.pdfDescribe the steps in Sanger DNA sequencing. Provide a high level des.pdf
Describe the steps in Sanger DNA sequencing. Provide a high level des.pdf
fatoryoutlets
 
Describe the advantages and disadvantages of the four standard acces.pdf
Describe the advantages and disadvantages of the four standard acces.pdfDescribe the advantages and disadvantages of the four standard acces.pdf
Describe the advantages and disadvantages of the four standard acces.pdf
fatoryoutlets
 
d. Which of the following accounts should be reviewed by the auditor.pdf
d. Which of the following accounts should be reviewed by the auditor.pdfd. Which of the following accounts should be reviewed by the auditor.pdf
d. Which of the following accounts should be reviewed by the auditor.pdf
fatoryoutlets
 

More from fatoryoutlets (20)

the ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdfthe ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdf
 
Template LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdfTemplate LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdf
 
Surface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdfSurface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdf
 
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdfSuppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
 
Q1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdfQ1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdf
 
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdfPrint Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
 
Part A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdfPart A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdf
 
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdfOnly 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
 
Note Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdfNote Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdf
 
Negotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdfNegotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdf
 
9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf
 
If law enforcement fails to give the defendant their Miranda rights,.pdf
If law enforcement fails to give the defendant their Miranda rights,.pdfIf law enforcement fails to give the defendant their Miranda rights,.pdf
If law enforcement fails to give the defendant their Miranda rights,.pdf
 
Identify one cyberattack that occurred in the last 2 years. What cau.pdf
Identify one cyberattack that occurred in the last 2 years. What cau.pdfIdentify one cyberattack that occurred in the last 2 years. What cau.pdf
Identify one cyberattack that occurred in the last 2 years. What cau.pdf
 
How do I add another txt.file to this Im trying to add this to be.pdf
How do I add another txt.file to this Im trying to add this to be.pdfHow do I add another txt.file to this Im trying to add this to be.pdf
How do I add another txt.file to this Im trying to add this to be.pdf
 
How you will respond empathetically, ethically, and legally to famil.pdf
How you will respond empathetically, ethically, and legally to famil.pdfHow you will respond empathetically, ethically, and legally to famil.pdf
How you will respond empathetically, ethically, and legally to famil.pdf
 
How can an insoluble salt with a basic anion be made to dissolve.pdf
How can an insoluble salt with a basic anion be made to dissolve.pdfHow can an insoluble salt with a basic anion be made to dissolve.pdf
How can an insoluble salt with a basic anion be made to dissolve.pdf
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdf
 
Describe the steps in Sanger DNA sequencing. Provide a high level des.pdf
Describe the steps in Sanger DNA sequencing. Provide a high level des.pdfDescribe the steps in Sanger DNA sequencing. Provide a high level des.pdf
Describe the steps in Sanger DNA sequencing. Provide a high level des.pdf
 
Describe the advantages and disadvantages of the four standard acces.pdf
Describe the advantages and disadvantages of the four standard acces.pdfDescribe the advantages and disadvantages of the four standard acces.pdf
Describe the advantages and disadvantages of the four standard acces.pdf
 
d. Which of the following accounts should be reviewed by the auditor.pdf
d. Which of the following accounts should be reviewed by the auditor.pdfd. Which of the following accounts should be reviewed by the auditor.pdf
d. Which of the following accounts should be reviewed by the auditor.pdf
 

Recently uploaded

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
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
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
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
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
 
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
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
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
 
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
 
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
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
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
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 

Recently uploaded (20)

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 ...
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
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...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
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
 
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
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
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
 
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
 
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
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
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
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 

Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf

  • 6. s5 p6 j2 200 s5 p6 j4 500 Note: Qty, status, and weight are numbers. Exercise 1. Get supplier names and numbers for all suppliers who supplied part P3 and whose name begins with letter A. 2. Get supplier names and numbers for all suppliers whose name (supplier name) begins with letter A and who supplied parts whose name (part’s name) begins with setter S. 3. Get supplier names for suppliers who supplied for job J2. (Use a sub query) 4. Get supplier names for suppliers who supplied parts for jobs only in Athens. (Use sub query) 5. Get part names for parts that are not supplied for job J3. (Use a sub query) 6. Get supplier numbers for suppliers with status lower than that of supplier S1. 7. Get supplier numbers and names for suppliers whose status is greater than status values of all suppliers in located Paris. 8. Calculate each supplier’s total sales quantity and get the sales person’s name if the sales person supplies parts more than 1000 units in total. 9. Get job numbers for jobs whose city is first in the alphabetical list of the job cities. 10. Increase the status values of suppliers by 5 who are located in Paris. Please hand in the modified table and the query. 11. Change the name to ‘Hammer’ of parts that are Red and located in London and whose name was Screw. Please hand in the modified table and the query. 12. Delete all jobs in Rome and all corresponding part shipments. (Please use 2 queries) Please hand in the modified table and the query. 13. Smith moved to Adam’s location. Please update Smith’s city but do not use the city name directly. 14. Please create a “view table” supplier_shipment that shows each supplier and its total shipment quantity. (if the system do not allow you to create a view table then skip this question) 15. Please try to increase Smith’s total shipment by 100 in the view table you created in question 14. Then discuss what happens when you try to update the view table. (if question 14 is
  • 7. successful) 16. Please create a base table supplier_shipment that shows each supplier and its total shipments from S and SPJ tables. 17. Please repeat question 15 on the base table supplier_shipment and discuss the result. Note: You might need following setting before run your update SQL SET SQL_SAFE_UPDATES = 0; j_num jname city j1 Sorter Paris j2 Punch Rome j3 Reader Athens j4 Console Athens j5 Collator London j6 Terminal Oslo j7 Tape London Solution If you have any doubts, please give me comment... -- 1. Get supplier names and numbers for all suppliers who supplied part P3 and whose name begins with letter A.
  • 8. SELECT s_name, s_num FROM S INNER JOIN SPJ ON S.s_num = SPJ.s_num WHERE s_name LIKE 'A%' AND p_num = P3; -- 2. Get supplier names and numbers for all suppliers whose name (supplier name) begins with letter A and who supplied parts whose name (part’s name) begins with setter S. SELECT s_name, s_num FROM (S INNER JOIN SPJ ON S.s_num = SPJ.s_num) INNER JOIN P ON SPJ.p_num = P.p_num WHERE s_name LIKE 'A%' AND pname = 'S%'; -- 3. Get supplier names for suppliers who supplied for job J2. (Use a sub query) SELECT s_num FROM S WHERE s_num IN( SELECT s_num FROM SPJ WHERE j_num = 'j2' ); -- 4. Get supplier names for suppliers who supplied parts for jobs only in Athens. (Use sub query) SELECT s_num FROM (S INNER JOIN SPJ ON S.s_num = SPJ.s_num) INNER JOIN J ON SPJ.j_num = J.j_num WHERE J.city = 'Athens' AND s_num NOT IN( SELECT s_num FROM (S INNER JOIN SPJ ON S.s_num = SPJ.s_num) INNER JOIN J ON SPJ.j_num = J.j_num WHERE J.city <> 'Athens' ); -- 5. Get part names for parts that are not supplied for job J3. (Use a sub query) SELECT pname FROM P WHERE p_num NOT IN( SELECT p_num FROM SPJ WHERE p_num = 'j3' );
  • 9. -- 6. Get supplier numbers for suppliers with status lower than that of supplier S1. SELECT s_num FROM S WHERE status < ( SELECT status FROM S WHERE s_num = 's1' ); -- 7. Get supplier numbers and names for suppliers whose status is greater than status values of all suppliers in located Paris. SELECT s_num, sname FROM S WHERE status > ALL( SELECT status FROM S WHERE city = Paris ); -- 8. Calculate each supplier’s total sales quantity and get the sales person’s name if the sales person supplies parts more than 1000 units in total. SELECT S.s_num, s_name, SUM(qty) FROM S INNER JOIN SPJ ON S.s_num = SPJ.s_num GROUP BY S.s_num,s_name HAVING SUM(qty)>1000; -- 9. Get job numbers for jobs whose city is first in the alphabetical list of the job cities. SELECT j_num FROM J WHERE j_num IN( SELECT j_num FROM J ORDER BY city LIMIT 1 ); -- 10. Increase the status values of suppliers by 5 who are located in Paris. -- Please hand in the modified table and the query. UPDATE S SET status = status+5 WHERE city ='Paris'; SELECT *
  • 10. FROM S; -- 11. Change the name to ‘Hammer’ of parts that are Red and located in London and whose name was Screw. -- Please hand in the modified table and the query. UPDATE P SET pname = 'Hammer' WHERE color = 'Red' AND city ='London' AND pname='Screw'; SELECT * FROM P; -- 12. Delete all jobs in Rome and all corresponding part shipments. (Please use 2 queries) -- Please hand in the modified table and the query. DELETE FROM SPJ WHERE j_num IN ( SELECT j_num FROM J WHERE city = 'Rome' ); DELETE FROM J WHERE city ='Rome'; -- 13. Smith moved to Adam’s location. Please update Smith’s city but do not use the city name directly. UPDATE S SET city = (SELECT city FROM S WHERE s_name='Adams') WHERE s_name='Smith'; -- 14. Please create a “view table” supplier_shipment that shows each supplier and its total shipment quantity. (if the system do not allow you to create a view table then skip this question) CREATE VIEW supplier_shipment AS SELECT s_num, SUM(qty) AS qty FROM SPJ GROUP s_num; -- 15. Please try to increase Smith’s total shipment by 100 in the view table you created in question 14. Then discuss what happens when you try to update the view table. (if question 14 is successful) UPDATE supplier_shipment SET qty = qty +100; -- 16. Please create a base table supplier_shipment that shows each supplier and its total shipments from S and SPJ tables. DESCRIBE supplier_shipment;