SlideShare a Scribd company logo
1 of 5
Download to read offline
You are requested to write the SQL commands to perform the following operations on the tables
in the CONSTRUCTION database.
TABLES IN THE CONSTRUCTION DATABASE
WORKER Table
Primary key: WORKER_ID
Foreign keys: none
WORKER_ID
WORKER_NAME
HRLY_RATE
SKILL_TYPE
1235
Faraday
12.50
Electric
1412
Nemo
13.75
Plumbing
2920
Garret
10.00
Roofing
3231
Mason
17.40
Framing
- etc.-
ASSIGNMENT Table
Primary key: WK_ID + BLDG_ID + START_DATE
Foreign keys: WK_ID (references the WORKER table)
BLDG_ID (references the BUILDING table)
WK_ID
BLDG_ID
START_DATE
NUM_DAYS
1235
321
2016-10-10
5
1412
321
2016-10-01
10
1235
515
2016-10-17
22
2920
460
2016-12-09
18
- etc.-
BUILDING Table
Primary key: BLDG_ID
Foreign keys: none
BLDG_ID
BLDG_ADDRESS
TYPE
QLTY_LEVEL
STATUS
321
123 Elm
Office
2
2
435
456 Maple
Retail
1
1
515
789 Oak
Residence
3
1
460
1011 Birch
Office
2
3
- etc.-
Quality Level is a major concern in building construction. List the number of buildings that have
a quality level of 2 or below and the names of employees working at these buildings.
WORKER_ID
WORKER_NAME
HRLY_RATE
SKILL_TYPE
1235
Faraday
12.50
Electric
1412
Nemo
13.75
Plumbing
2920
Garret
10.00
Roofing
3231
Mason
17.40
Framing
- etc.-
Solution
CREATE TABLE WORKER
(
WORKER_ID NUMBER(5) NOT NULL,
WORKER_NAME VARCHAR2(100),
HRLY_RATE NUMBER(4,2),
SKILL_TYPE VARCHAR2(50),
CONSTRAINT WORKER_PK PRIMARY KEY (WORKER_ID)
);
CREATE TABLE BUILDING
(
BLDG_ID NUMBER(4),
BLDG_ADDRESS VARCHAR2(200),
TYPE VARCHAR2(50),
QLTY_LEVEL INT,
STATUS INT,
CONSTRAINT BUILDING_PK PRIMARY KEY (BLDG_ID)
);
CREATE TABLE ASSIGNMENT
(
WK_ID NUMBER(5),
BLDG_ID NUMBER(4),
START_DATE DATE,
NUM_DAYS INT,
CONSTRAINT ASSIGNMENT_PK PRIMARY KEY (WK_ID,BLDG_ID,START_DATE),
CONSTRAINT FK_WORKER
FOREIGN KEY (WK_ID)
REFERENCES WORKER(WORKER_ID),
CONSTRAINT FK_BUILDING
FOREIGN KEY (BLDG_ID)
REFERENCES BUILDING(BLDG_ID)
);
SELECT COUNT(B.BLDG_ID), W.WORKER_NAME
FROM
BUILDING B, WORKER W
WHERE WORKER.WORKER_ID IN (SELECT WK_ID FROM ASSIGNMENT WHERE
B.BLDG_ID IN
(SELECT BLDG_ID FROM BUILDING WHERE QLTY_LEVEL < 3))
;

More Related Content

Similar to You are requested to write the SQL commands to perform the following.pdf

Similar to You are requested to write the SQL commands to perform the following.pdf (17)

Sq lite module8
Sq lite module8Sq lite module8
Sq lite module8
 
SQL-PL and DB2 Objects
SQL-PL and DB2 ObjectsSQL-PL and DB2 Objects
SQL-PL and DB2 Objects
 
MS SQL - Database Programming Concepts by RSolutions
MS SQL - Database Programming Concepts by RSolutionsMS SQL - Database Programming Concepts by RSolutions
MS SQL - Database Programming Concepts by RSolutions
 
RDBMS to NoSQL: Practical Advice from Successful Migrations
RDBMS to NoSQL: Practical Advice from Successful MigrationsRDBMS to NoSQL: Practical Advice from Successful Migrations
RDBMS to NoSQL: Practical Advice from Successful Migrations
 
Assembly Language Lecture 3
Assembly Language Lecture 3Assembly Language Lecture 3
Assembly Language Lecture 3
 
LA Micro Stock Report 12th November 2013
 LA Micro Stock Report 12th November 2013 LA Micro Stock Report 12th November 2013
LA Micro Stock Report 12th November 2013
 
LA Micro Stock Report 13th November 2013
 LA Micro Stock Report 13th November 2013 LA Micro Stock Report 13th November 2013
LA Micro Stock Report 13th November 2013
 
My Sql concepts
My Sql conceptsMy Sql concepts
My Sql concepts
 
Sql for biggner
Sql for biggnerSql for biggner
Sql for biggner
 
SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3SQL302 Intermediate SQL Workshop 3
SQL302 Intermediate SQL Workshop 3
 
SQL Database Performance Tuning for Developers
SQL Database Performance Tuning for DevelopersSQL Database Performance Tuning for Developers
SQL Database Performance Tuning for Developers
 
SQL NAD DB.pptx
SQL NAD DB.pptxSQL NAD DB.pptx
SQL NAD DB.pptx
 
chapter 8 SQL.ppt
chapter 8 SQL.pptchapter 8 SQL.ppt
chapter 8 SQL.ppt
 
SQL
SQLSQL
SQL
 
Chap 7
Chap 7Chap 7
Chap 7
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
Oracle vs. SQL Server- War of the Indices
Oracle vs. SQL Server- War of the IndicesOracle vs. SQL Server- War of the Indices
Oracle vs. SQL Server- War of the Indices
 

More from PRATIKSINHA7304

A new class will be added to the startup package to start up the eve.pdf
A new class will be added to the startup package to start up the eve.pdfA new class will be added to the startup package to start up the eve.pdf
A new class will be added to the startup package to start up the eve.pdf
PRATIKSINHA7304
 
Are these statements regarding Rhizobacteria true Plant Growth P.pdf
Are these statements regarding Rhizobacteria true Plant Growth P.pdfAre these statements regarding Rhizobacteria true Plant Growth P.pdf
Are these statements regarding Rhizobacteria true Plant Growth P.pdf
PRATIKSINHA7304
 
Wiater Company operates a small manufacturing facility. On January 1,.pdf
Wiater Company operates a small manufacturing facility. On January 1,.pdfWiater Company operates a small manufacturing facility. On January 1,.pdf
Wiater Company operates a small manufacturing facility. On January 1,.pdf
PRATIKSINHA7304
 
Which of the three types of activities reported on the statement of c.pdf
Which of the three types of activities reported on the statement of c.pdfWhich of the three types of activities reported on the statement of c.pdf
Which of the three types of activities reported on the statement of c.pdf
PRATIKSINHA7304
 
What are the pros and cons of using exFAT and ReFS on a Windows 2012.pdf
What are the pros and cons of using exFAT and ReFS on a Windows 2012.pdfWhat are the pros and cons of using exFAT and ReFS on a Windows 2012.pdf
What are the pros and cons of using exFAT and ReFS on a Windows 2012.pdf
PRATIKSINHA7304
 
What is the connection between relative frequency and probability.pdf
What is the connection between relative frequency and probability.pdfWhat is the connection between relative frequency and probability.pdf
What is the connection between relative frequency and probability.pdf
PRATIKSINHA7304
 
unixlinux - kernelexplain yield in user spaceexplain yield in k.pdf
unixlinux - kernelexplain yield in user spaceexplain yield in k.pdfunixlinux - kernelexplain yield in user spaceexplain yield in k.pdf
unixlinux - kernelexplain yield in user spaceexplain yield in k.pdf
PRATIKSINHA7304
 

More from PRATIKSINHA7304 (20)

Hi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfHi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdf
 
Find the sum of the infinite geometric series if it exists. (If an .pdf
Find the sum of the infinite geometric series if it exists. (If an .pdfFind the sum of the infinite geometric series if it exists. (If an .pdf
Find the sum of the infinite geometric series if it exists. (If an .pdf
 
A new class will be added to the startup package to start up the eve.pdf
A new class will be added to the startup package to start up the eve.pdfA new class will be added to the startup package to start up the eve.pdf
A new class will be added to the startup package to start up the eve.pdf
 
Are these statements regarding Rhizobacteria true Plant Growth P.pdf
Are these statements regarding Rhizobacteria true Plant Growth P.pdfAre these statements regarding Rhizobacteria true Plant Growth P.pdf
Are these statements regarding Rhizobacteria true Plant Growth P.pdf
 
1. Prices may be different between two countries whenA. Both count.pdf
1. Prices may be different between two countries whenA. Both count.pdf1. Prices may be different between two countries whenA. Both count.pdf
1. Prices may be different between two countries whenA. Both count.pdf
 
[10 points]Add the.pdf
[10 points]Add the.pdf[10 points]Add the.pdf
[10 points]Add the.pdf
 
§ 7.3 7.6 Which member of the following pairs is likely to decompose .pdf
§ 7.3 7.6 Which member of the following pairs is likely to decompose .pdf§ 7.3 7.6 Which member of the following pairs is likely to decompose .pdf
§ 7.3 7.6 Which member of the following pairs is likely to decompose .pdf
 
write a prgoram that displays four images or objects in a 2 x 2 grid.pdf
write a prgoram that displays four images or objects in a 2 x 2 grid.pdfwrite a prgoram that displays four images or objects in a 2 x 2 grid.pdf
write a prgoram that displays four images or objects in a 2 x 2 grid.pdf
 
Wiater Company operates a small manufacturing facility. On January 1,.pdf
Wiater Company operates a small manufacturing facility. On January 1,.pdfWiater Company operates a small manufacturing facility. On January 1,.pdf
Wiater Company operates a small manufacturing facility. On January 1,.pdf
 
Which of the three types of activities reported on the statement of c.pdf
Which of the three types of activities reported on the statement of c.pdfWhich of the three types of activities reported on the statement of c.pdf
Which of the three types of activities reported on the statement of c.pdf
 
111. Definition Explanation (15) 1. Job speciation SolutionIII.pdf
111. Definition Explanation (15) 1. Job speciation SolutionIII.pdf111. Definition Explanation (15) 1. Job speciation SolutionIII.pdf
111. Definition Explanation (15) 1. Job speciation SolutionIII.pdf
 
What are the pros and cons of using exFAT and ReFS on a Windows 2012.pdf
What are the pros and cons of using exFAT and ReFS on a Windows 2012.pdfWhat are the pros and cons of using exFAT and ReFS on a Windows 2012.pdf
What are the pros and cons of using exFAT and ReFS on a Windows 2012.pdf
 
What led to the demise of ‘conventional Keynesian wisdom’ in the mid.pdf
What led to the demise of ‘conventional Keynesian wisdom’ in the mid.pdfWhat led to the demise of ‘conventional Keynesian wisdom’ in the mid.pdf
What led to the demise of ‘conventional Keynesian wisdom’ in the mid.pdf
 
What is the connection between relative frequency and probability.pdf
What is the connection between relative frequency and probability.pdfWhat is the connection between relative frequency and probability.pdf
What is the connection between relative frequency and probability.pdf
 
What factors led President Truman to support the creation of Israel .pdf
What factors led President Truman to support the creation of Israel .pdfWhat factors led President Truman to support the creation of Israel .pdf
What factors led President Truman to support the creation of Israel .pdf
 
unixlinux - kernelexplain yield in user spaceexplain yield in k.pdf
unixlinux - kernelexplain yield in user spaceexplain yield in k.pdfunixlinux - kernelexplain yield in user spaceexplain yield in k.pdf
unixlinux - kernelexplain yield in user spaceexplain yield in k.pdf
 
this is java. problem.i already make employee class. but i can not.pdf
this is java. problem.i already make employee class. but i can not.pdfthis is java. problem.i already make employee class. but i can not.pdf
this is java. problem.i already make employee class. but i can not.pdf
 
This fall Millie finally repaid her student loan. She originally bor.pdf
This fall Millie finally repaid her student loan. She originally bor.pdfThis fall Millie finally repaid her student loan. She originally bor.pdf
This fall Millie finally repaid her student loan. She originally bor.pdf
 
The term refers to a. Global Analysis of the proteins produced in .pdf
The term  refers to  a. Global Analysis of the proteins produced in .pdfThe term  refers to  a. Global Analysis of the proteins produced in .pdf
The term refers to a. Global Analysis of the proteins produced in .pdf
 
The inflation rate of Country Alpha in 2014 was 3.5. Due to their w.pdf
The inflation rate of Country Alpha in 2014 was 3.5. Due to their w.pdfThe inflation rate of Country Alpha in 2014 was 3.5. Due to their w.pdf
The inflation rate of Country Alpha in 2014 was 3.5. Due to their w.pdf
 

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 

You are requested to write the SQL commands to perform the following.pdf

  • 1. You are requested to write the SQL commands to perform the following operations on the tables in the CONSTRUCTION database. TABLES IN THE CONSTRUCTION DATABASE WORKER Table Primary key: WORKER_ID Foreign keys: none WORKER_ID WORKER_NAME HRLY_RATE SKILL_TYPE 1235 Faraday 12.50 Electric 1412 Nemo 13.75 Plumbing 2920 Garret 10.00 Roofing 3231 Mason 17.40 Framing - etc.- ASSIGNMENT Table Primary key: WK_ID + BLDG_ID + START_DATE Foreign keys: WK_ID (references the WORKER table) BLDG_ID (references the BUILDING table) WK_ID BLDG_ID START_DATE
  • 2. NUM_DAYS 1235 321 2016-10-10 5 1412 321 2016-10-01 10 1235 515 2016-10-17 22 2920 460 2016-12-09 18 - etc.- BUILDING Table Primary key: BLDG_ID Foreign keys: none BLDG_ID BLDG_ADDRESS TYPE QLTY_LEVEL STATUS 321 123 Elm Office 2 2 435 456 Maple Retail 1 1
  • 3. 515 789 Oak Residence 3 1 460 1011 Birch Office 2 3 - etc.- Quality Level is a major concern in building construction. List the number of buildings that have a quality level of 2 or below and the names of employees working at these buildings. WORKER_ID WORKER_NAME HRLY_RATE SKILL_TYPE 1235 Faraday 12.50 Electric 1412 Nemo 13.75 Plumbing 2920 Garret 10.00 Roofing 3231 Mason 17.40 Framing - etc.- Solution
  • 4. CREATE TABLE WORKER ( WORKER_ID NUMBER(5) NOT NULL, WORKER_NAME VARCHAR2(100), HRLY_RATE NUMBER(4,2), SKILL_TYPE VARCHAR2(50), CONSTRAINT WORKER_PK PRIMARY KEY (WORKER_ID) ); CREATE TABLE BUILDING ( BLDG_ID NUMBER(4), BLDG_ADDRESS VARCHAR2(200), TYPE VARCHAR2(50), QLTY_LEVEL INT, STATUS INT, CONSTRAINT BUILDING_PK PRIMARY KEY (BLDG_ID) ); CREATE TABLE ASSIGNMENT ( WK_ID NUMBER(5), BLDG_ID NUMBER(4), START_DATE DATE, NUM_DAYS INT, CONSTRAINT ASSIGNMENT_PK PRIMARY KEY (WK_ID,BLDG_ID,START_DATE), CONSTRAINT FK_WORKER FOREIGN KEY (WK_ID) REFERENCES WORKER(WORKER_ID), CONSTRAINT FK_BUILDING FOREIGN KEY (BLDG_ID) REFERENCES BUILDING(BLDG_ID) ); SELECT COUNT(B.BLDG_ID), W.WORKER_NAME FROM
  • 5. BUILDING B, WORKER W WHERE WORKER.WORKER_ID IN (SELECT WK_ID FROM ASSIGNMENT WHERE B.BLDG_ID IN (SELECT BLDG_ID FROM BUILDING WHERE QLTY_LEVEL < 3)) ;