SlideShare a Scribd company logo
1 of 7
SQL Midterm
To Purchase This Material Click below Link
http://www.tutorialoutlet.com/all-miscellaneous/sql-
midterm/
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
SQL Midterm (200 points max)
General Instructions: You must use Dropbox in Folio for posting
strictly individual solutions. In addition use the
provided cover page, from the syllabus, and elaborate lessons learned
(reflection of the problems and your efforts, your
conclusion regarding the value of performance analysis of SQL query
alternative, and anything else worth remembering
from this assignment). No late submission will be accepted, and you
are strongly advised to work over a period of at
least 10 days while planning to complete all at least one day before
the deadline.
Part I problem set. (100 points). This portion deals with the DB
evolution, expect to invest min 8-10 hours of work.
ITEM DEPAR TMENT item name dept name item type
item color empid (FK)
dept f loor
dept phone
QSALE
saleno EMPLOY EE Saleqt y
dept name (FK)
item name (FK) empid
empf name
emplname
empsalary
empaddres s
dept name (FK)
boss (FK) SUPLIER
suplid
DELIVER Y
delidsuplname
supladdressdelqt y
suplid (FK)
delinstruc t
itemname (FK)
dept name (FK) Starting with the QSALE DB, implemented in
Oracle, apply the following changes to the DB definitions and/or
content:
Step 1: Add delivery-date and sales-date toData
QDEL
andillustrating
QSALE tables
and populate (update them) with random dates in
Model
QSALE,
2010 and 2011 respectively.
the SQL Playbook databse
Step 2: Add QtyOnHand field for representing the quantity i.e. level
of a current inventory in QITEM table and set up
initial (but not default) values to a 100.
Step 3: Update QITEM inventory as follows:
a Using QDEL existing records (as a basis for transaction) subtract if
delivery was to a consuming (administrative
or management departments, make a view of those first), and add to
the inventory if delivery was to other
departments.
b Similarly use existing QSALE records (as a basis for transactions)
to diminish the inventory.
c Provide Inventory status report indicating QtyOnHand under ‘safe’
level of 100.
d How would you, for all items with a quantity on hands value under
a 100, trigger (i.e. automate) a delivery, of a
random replenishing value between 100 and 200, to (only the) sale
departments with the sales that depleted an
item to level under 100?
e How would you take care, if necessary, in cases of items that had no
deliveries (unknown supplier) or sales
attempting to sell more than the available quantity on hand?
f
Suggestion: Visualize DB before starting process of changes and
visualize every structural content change
Note: Test all work/changes above as you go (typically using select *
from … statements).
Step 4: Purpose of this step is mainly to transfer recursive relationship
form QEMP to a new table replacing QDEPT
a) Reconstruct QEMP table so that BOSS information from QEMP
table became MANAGER information in a
new QORG table (to be derived from QDEPT). Expand the QORG by
inserting a ‘SUNRISE’ (company) as
organizational unit managed by the top BOSS (but use a query on
QEMP to determine the top BOSS,
employee that have no BOSS but serving as a BOSS to at least one
other employee.
Discuss potential difficulties in reporting if you have the same person
managing more than one department
or the whole company in addition to one of the departments.
After accomplishing previous tasks of this step, the QEMP table will
also need to be changed in the following manner:
b) add employment dates, for every employee using random dates in
2007,
c) remove the BOSS information from QEMP. d) The old QDEPT is
to be deletinformation is
successfully migrated to new QORG table. Step 5: Insert five
salespersons, hired as employees working in departments involved
with sales in the 2012 (insert five
records with made up employment date in 2013).
Step 6: Create QCUSTOMER table with 20 prospects and generate
one possible sale to each in 2014, keeping inventory
information updated (automatically if possible). Note a need to
expand QSALE to include FK of the customer (an
optional field as they could still be some sales made by unidentified
customers as well as for a backward compatibility).
Step 7: In January 2015 the SUNRISE company started accepting
mail orders for multiple ITEMS and started fulfilling
sales for them assuming sufficient inventory. To keep old system
intact new tables are to be created to handle multiline
order fulfillment. Show DDL code (for new tables ORDER and
ORDERLINE) and illustrate with a few transactions
(inserts producing new representative records). The SUNRISE in
January 2015 also started to accept payments by
Credit card for all mail orders whenever inventory is sufficient.
Step 8: SUNRISE is adding its own automatic orders SORDERS to
suppliers to initiate delivery of all ITEMS when
their quantity at hand reaches a certain minimal level (but now instead
of a 100 being the safe level, company opted for
variable level declared to be equivalent to the 10% of the item’s
average qty on hand for the past year. Please note that a
running average needs to be calculated during the current year and
kept for the past year as well). So discuss what
triggers needs to be made that will use a function for calculating
running avg and maintaining safe levels of the
inventory. How would you prepare, in 2016, for this new functionality
in order to be ready for 2017 (especially
automating end of year processing).
Step 9: SUNRISE is considering expanding the DB with INVOICES
to old customers (if inventory on hand cannot
completely fulfill an order), but will still accept new customers for
orders that can be completely fulfilled from on hand
inventory.
Step 10: To demonstrate value of the newly completed DB design,
create four intermediate level SQL queries, not
possible with the old QSALE DB design, illustrating interests of
various stakeholders (managers, customers, suppliers,
and employees). In addition create necessary views to assure that any
queries that worked with the original QSALE DB
work without changes. Part II problem set (100 points max). Expected
effort is 5+ hours. This part will cover exploration of SQL query
alternatives for selected problem patterns. You can user both
SQL Server and Oracle (in case of differ possible syntax) but to count
each query must be true alternative
meaning their execution/explain plans must be different. Always
inspect data content first to visualize what
can be expected. Make sure to test your code and demonstrate validity
of each solution!
Here the number of correct queries and their originality count towards
the grade.
Problem #1 (50 points max) – not so easy
Given a QDEL table from the (old i.e. original) QSALE DB provide
as many alternatives in SQL to select every fifth
record.
Problem #2 (50 points max) – moderate
Given a QITEM table, from the QSALE DB, copy its content into
NEWITEM table. Make three unrelated but elementary changes (one
record update, one new record insert, and one old
record delete) in NEWITEM table.
a) Provide as many different ways using SQL (but no stored
procedures or triggers) to accomplish the
following task: compare the tables QITEM and NEWITEM to assess
if they are now exactly the same.

More Related Content

Viewers also liked

Rojo pdf lattice2017-nnpdf
Rojo pdf lattice2017-nnpdfRojo pdf lattice2017-nnpdf
Rojo pdf lattice2017-nnpdfjuanrojochacon
 
GRASPSKILLS HANDBOOK
GRASPSKILLS HANDBOOKGRASPSKILLS HANDBOOK
GRASPSKILLS HANDBOOKgraspskills
 
Metodos de programacion no lineal javier perez
Metodos de programacion no lineal javier perezMetodos de programacion no lineal javier perez
Metodos de programacion no lineal javier perezjavier peeez
 
лапта
лапталапта
лаптаdenchk
 
Measuring emotional contagion in social media
Measuring emotional contagion in social mediaMeasuring emotional contagion in social media
Measuring emotional contagion in social mediafatimanafie
 
La teoria-de-los-cuatro-humores (2)
La teoria-de-los-cuatro-humores (2)La teoria-de-los-cuatro-humores (2)
La teoria-de-los-cuatro-humores (2)Ángeles Pérez
 
THE INVOLVEMENT OF YOUTH CORP MEMBERS IN TEACHING IN NIGERIA: MATTERS ARISING...
THE INVOLVEMENT OF YOUTH CORP MEMBERS IN TEACHING IN NIGERIA: MATTERS ARISING...THE INVOLVEMENT OF YOUTH CORP MEMBERS IN TEACHING IN NIGERIA: MATTERS ARISING...
THE INVOLVEMENT OF YOUTH CORP MEMBERS IN TEACHING IN NIGERIA: MATTERS ARISING...paperpublications3
 
Beton prategangz (1) (3)
Beton prategangz (1) (3)Beton prategangz (1) (3)
Beton prategangz (1) (3)wildan grenadi
 

Viewers also liked (10)

Mis 582 exam
Mis 582 examMis 582 exam
Mis 582 exam
 
Rojo pdf lattice2017-nnpdf
Rojo pdf lattice2017-nnpdfRojo pdf lattice2017-nnpdf
Rojo pdf lattice2017-nnpdf
 
GRASPSKILLS HANDBOOK
GRASPSKILLS HANDBOOKGRASPSKILLS HANDBOOK
GRASPSKILLS HANDBOOK
 
Metodos de programacion no lineal javier perez
Metodos de programacion no lineal javier perezMetodos de programacion no lineal javier perez
Metodos de programacion no lineal javier perez
 
лапта
лапталапта
лапта
 
Measuring emotional contagion in social media
Measuring emotional contagion in social mediaMeasuring emotional contagion in social media
Measuring emotional contagion in social media
 
La teoria-de-los-cuatro-humores (2)
La teoria-de-los-cuatro-humores (2)La teoria-de-los-cuatro-humores (2)
La teoria-de-los-cuatro-humores (2)
 
R e
R eR e
R e
 
THE INVOLVEMENT OF YOUTH CORP MEMBERS IN TEACHING IN NIGERIA: MATTERS ARISING...
THE INVOLVEMENT OF YOUTH CORP MEMBERS IN TEACHING IN NIGERIA: MATTERS ARISING...THE INVOLVEMENT OF YOUTH CORP MEMBERS IN TEACHING IN NIGERIA: MATTERS ARISING...
THE INVOLVEMENT OF YOUTH CORP MEMBERS IN TEACHING IN NIGERIA: MATTERS ARISING...
 
Beton prategangz (1) (3)
Beton prategangz (1) (3)Beton prategangz (1) (3)
Beton prategangz (1) (3)
 

Similar to Sql midterm

Dan Querimit - BI Portfolio
Dan Querimit - BI PortfolioDan Querimit - BI Portfolio
Dan Querimit - BI Portfolioquerimit
 
SetFocus SQL Portfolio
SetFocus SQL PortfolioSetFocus SQL Portfolio
SetFocus SQL Portfoliogeometro17
 
Kevin Fahy Bi Portfolio
Kevin Fahy   Bi PortfolioKevin Fahy   Bi Portfolio
Kevin Fahy Bi PortfolioKevinPFahy
 
Create a sql script containing your data definition language (ddl)
Create a sql script containing your data definition language (ddl)Create a sql script containing your data definition language (ddl)
Create a sql script containing your data definition language (ddl)RAJU852744
 
Nitin\'s Business Intelligence Portfolio
Nitin\'s Business Intelligence PortfolioNitin\'s Business Intelligence Portfolio
Nitin\'s Business Intelligence Portfolionpatel2362
 
Leveraging IBM Cognos TM1 for Merchandise Planning at Tractor Supply Company ...
Leveraging IBM Cognos TM1 for Merchandise Planning at Tractor Supply Company ...Leveraging IBM Cognos TM1 for Merchandise Planning at Tractor Supply Company ...
Leveraging IBM Cognos TM1 for Merchandise Planning at Tractor Supply Company ...QueBIT Consulting
 
1 ACC ACF 2400 – Semester 2, 2017 Individual Assignm.docx
1  ACC ACF 2400 – Semester 2, 2017  Individual Assignm.docx1  ACC ACF 2400 – Semester 2, 2017  Individual Assignm.docx
1 ACC ACF 2400 – Semester 2, 2017 Individual Assignm.docxhoney725342
 
Performance Tuning Oracle's BI Applications
Performance Tuning Oracle's BI ApplicationsPerformance Tuning Oracle's BI Applications
Performance Tuning Oracle's BI ApplicationsKPI Partners
 
Ca 10 G1 John Buickerood Portfolio
Ca 10 G1 John Buickerood PortfolioCa 10 G1 John Buickerood Portfolio
Ca 10 G1 John Buickerood PortfolioJohn_Buickerood
 
Microsoft MCSE 70-467 it exams dumps
Microsoft MCSE 70-467 it exams dumpsMicrosoft MCSE 70-467 it exams dumps
Microsoft MCSE 70-467 it exams dumpslilylucy
 
fdocuments.in_the-model-clause-explained (1).pptx
fdocuments.in_the-model-clause-explained (1).pptxfdocuments.in_the-model-clause-explained (1).pptx
fdocuments.in_the-model-clause-explained (1).pptxhesham alataby
 
OPS 571 HELP Lessons in Excellence / ops571help.com
OPS 571 HELP Lessons in Excellence / ops571help.comOPS 571 HELP Lessons in Excellence / ops571help.com
OPS 571 HELP Lessons in Excellence / ops571help.comkopiko46
 
OPS 571 HELP Education Counseling--ops571help.com
OPS 571 HELP Education Counseling--ops571help.comOPS 571 HELP Education Counseling--ops571help.com
OPS 571 HELP Education Counseling--ops571help.comvenkat60041
 
COA Masterclass 2022.pdf
COA Masterclass 2022.pdfCOA Masterclass 2022.pdf
COA Masterclass 2022.pdfeprentise
 
OPS 571 GENIUS Education Counseling--ops571genius.com
OPS 571 GENIUS Education Counseling--ops571genius.comOPS 571 GENIUS Education Counseling--ops571genius.com
OPS 571 GENIUS Education Counseling--ops571genius.comvenkat60040
 
OPS 571 GENIUS Inspiring Innovation--ops571genius.com
OPS 571 GENIUS Inspiring Innovation--ops571genius.comOPS 571 GENIUS Inspiring Innovation--ops571genius.com
OPS 571 GENIUS Inspiring Innovation--ops571genius.comkopiko111
 
OPS 571 HELP Education Counseling--ops571help.com
OPS 571 HELP Education Counseling--ops571help.comOPS 571 HELP Education Counseling--ops571help.com
OPS 571 HELP Education Counseling--ops571help.comKeatonJennings64
 
OPS 571 HELP Become Exceptional--ops571help.com
 OPS 571 HELP Become Exceptional--ops571help.com OPS 571 HELP Become Exceptional--ops571help.com
OPS 571 HELP Become Exceptional--ops571help.comagathachristie127
 
Technical Presentation - TimeWIzard
Technical Presentation - TimeWIzardTechnical Presentation - TimeWIzard
Technical Presentation - TimeWIzardPraveen Kumar Peddi
 

Similar to Sql midterm (20)

Dan Querimit - BI Portfolio
Dan Querimit - BI PortfolioDan Querimit - BI Portfolio
Dan Querimit - BI Portfolio
 
SetFocus SQL Portfolio
SetFocus SQL PortfolioSetFocus SQL Portfolio
SetFocus SQL Portfolio
 
Kevin Fahy Bi Portfolio
Kevin Fahy   Bi PortfolioKevin Fahy   Bi Portfolio
Kevin Fahy Bi Portfolio
 
Create a sql script containing your data definition language (ddl)
Create a sql script containing your data definition language (ddl)Create a sql script containing your data definition language (ddl)
Create a sql script containing your data definition language (ddl)
 
Nitin\'s Business Intelligence Portfolio
Nitin\'s Business Intelligence PortfolioNitin\'s Business Intelligence Portfolio
Nitin\'s Business Intelligence Portfolio
 
Leveraging IBM Cognos TM1 for Merchandise Planning at Tractor Supply Company ...
Leveraging IBM Cognos TM1 for Merchandise Planning at Tractor Supply Company ...Leveraging IBM Cognos TM1 for Merchandise Planning at Tractor Supply Company ...
Leveraging IBM Cognos TM1 for Merchandise Planning at Tractor Supply Company ...
 
1 ACC ACF 2400 – Semester 2, 2017 Individual Assignm.docx
1  ACC ACF 2400 – Semester 2, 2017  Individual Assignm.docx1  ACC ACF 2400 – Semester 2, 2017  Individual Assignm.docx
1 ACC ACF 2400 – Semester 2, 2017 Individual Assignm.docx
 
Performance Tuning Oracle's BI Applications
Performance Tuning Oracle's BI ApplicationsPerformance Tuning Oracle's BI Applications
Performance Tuning Oracle's BI Applications
 
Ca 10 G1 John Buickerood Portfolio
Ca 10 G1 John Buickerood PortfolioCa 10 G1 John Buickerood Portfolio
Ca 10 G1 John Buickerood Portfolio
 
Microsoft MCSE 70-467 it exams dumps
Microsoft MCSE 70-467 it exams dumpsMicrosoft MCSE 70-467 it exams dumps
Microsoft MCSE 70-467 it exams dumps
 
fdocuments.in_the-model-clause-explained (1).pptx
fdocuments.in_the-model-clause-explained (1).pptxfdocuments.in_the-model-clause-explained (1).pptx
fdocuments.in_the-model-clause-explained (1).pptx
 
OPS 571 HELP Lessons in Excellence / ops571help.com
OPS 571 HELP Lessons in Excellence / ops571help.comOPS 571 HELP Lessons in Excellence / ops571help.com
OPS 571 HELP Lessons in Excellence / ops571help.com
 
OPS 571 HELP Education Counseling--ops571help.com
OPS 571 HELP Education Counseling--ops571help.comOPS 571 HELP Education Counseling--ops571help.com
OPS 571 HELP Education Counseling--ops571help.com
 
COA Masterclass 2022.pdf
COA Masterclass 2022.pdfCOA Masterclass 2022.pdf
COA Masterclass 2022.pdf
 
OPS 571 GENIUS Education Counseling--ops571genius.com
OPS 571 GENIUS Education Counseling--ops571genius.comOPS 571 GENIUS Education Counseling--ops571genius.com
OPS 571 GENIUS Education Counseling--ops571genius.com
 
OPS 571 GENIUS Inspiring Innovation--ops571genius.com
OPS 571 GENIUS Inspiring Innovation--ops571genius.comOPS 571 GENIUS Inspiring Innovation--ops571genius.com
OPS 571 GENIUS Inspiring Innovation--ops571genius.com
 
OPS 571 HELP Education Counseling--ops571help.com
OPS 571 HELP Education Counseling--ops571help.comOPS 571 HELP Education Counseling--ops571help.com
OPS 571 HELP Education Counseling--ops571help.com
 
OPS 571 HELP Become Exceptional--ops571help.com
 OPS 571 HELP Become Exceptional--ops571help.com OPS 571 HELP Become Exceptional--ops571help.com
OPS 571 HELP Become Exceptional--ops571help.com
 
Technical Presentation - TimeWIzard
Technical Presentation - TimeWIzardTechnical Presentation - TimeWIzard
Technical Presentation - TimeWIzard
 
SQL Tunning
SQL TunningSQL Tunning
SQL Tunning
 

Recently uploaded

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 

Recently uploaded (20)

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 

Sql midterm

  • 1. SQL Midterm To Purchase This Material Click below Link http://www.tutorialoutlet.com/all-miscellaneous/sql- midterm/ FOR MORE CLASSES VISIT www.tutorialoutlet.com SQL Midterm (200 points max) General Instructions: You must use Dropbox in Folio for posting strictly individual solutions. In addition use the provided cover page, from the syllabus, and elaborate lessons learned (reflection of the problems and your efforts, your conclusion regarding the value of performance analysis of SQL query alternative, and anything else worth remembering from this assignment). No late submission will be accepted, and you are strongly advised to work over a period of at least 10 days while planning to complete all at least one day before the deadline. Part I problem set. (100 points). This portion deals with the DB evolution, expect to invest min 8-10 hours of work. ITEM DEPAR TMENT item name dept name item type item color empid (FK) dept f loor dept phone
  • 2. QSALE saleno EMPLOY EE Saleqt y dept name (FK) item name (FK) empid empf name emplname empsalary empaddres s dept name (FK) boss (FK) SUPLIER suplid DELIVER Y delidsuplname supladdressdelqt y suplid (FK) delinstruc t itemname (FK) dept name (FK) Starting with the QSALE DB, implemented in Oracle, apply the following changes to the DB definitions and/or content: Step 1: Add delivery-date and sales-date toData QDEL
  • 3. andillustrating QSALE tables and populate (update them) with random dates in Model QSALE, 2010 and 2011 respectively. the SQL Playbook databse Step 2: Add QtyOnHand field for representing the quantity i.e. level of a current inventory in QITEM table and set up initial (but not default) values to a 100. Step 3: Update QITEM inventory as follows: a Using QDEL existing records (as a basis for transaction) subtract if delivery was to a consuming (administrative or management departments, make a view of those first), and add to the inventory if delivery was to other departments. b Similarly use existing QSALE records (as a basis for transactions) to diminish the inventory. c Provide Inventory status report indicating QtyOnHand under ‘safe’ level of 100. d How would you, for all items with a quantity on hands value under a 100, trigger (i.e. automate) a delivery, of a random replenishing value between 100 and 200, to (only the) sale departments with the sales that depleted an
  • 4. item to level under 100? e How would you take care, if necessary, in cases of items that had no deliveries (unknown supplier) or sales attempting to sell more than the available quantity on hand? f Suggestion: Visualize DB before starting process of changes and visualize every structural content change Note: Test all work/changes above as you go (typically using select * from … statements). Step 4: Purpose of this step is mainly to transfer recursive relationship form QEMP to a new table replacing QDEPT a) Reconstruct QEMP table so that BOSS information from QEMP table became MANAGER information in a new QORG table (to be derived from QDEPT). Expand the QORG by inserting a ‘SUNRISE’ (company) as organizational unit managed by the top BOSS (but use a query on QEMP to determine the top BOSS, employee that have no BOSS but serving as a BOSS to at least one other employee. Discuss potential difficulties in reporting if you have the same person managing more than one department or the whole company in addition to one of the departments. After accomplishing previous tasks of this step, the QEMP table will also need to be changed in the following manner: b) add employment dates, for every employee using random dates in 2007,
  • 5. c) remove the BOSS information from QEMP. d) The old QDEPT is to be deletinformation is successfully migrated to new QORG table. Step 5: Insert five salespersons, hired as employees working in departments involved with sales in the 2012 (insert five records with made up employment date in 2013). Step 6: Create QCUSTOMER table with 20 prospects and generate one possible sale to each in 2014, keeping inventory information updated (automatically if possible). Note a need to expand QSALE to include FK of the customer (an optional field as they could still be some sales made by unidentified customers as well as for a backward compatibility). Step 7: In January 2015 the SUNRISE company started accepting mail orders for multiple ITEMS and started fulfilling sales for them assuming sufficient inventory. To keep old system intact new tables are to be created to handle multiline order fulfillment. Show DDL code (for new tables ORDER and ORDERLINE) and illustrate with a few transactions (inserts producing new representative records). The SUNRISE in January 2015 also started to accept payments by Credit card for all mail orders whenever inventory is sufficient. Step 8: SUNRISE is adding its own automatic orders SORDERS to suppliers to initiate delivery of all ITEMS when their quantity at hand reaches a certain minimal level (but now instead of a 100 being the safe level, company opted for variable level declared to be equivalent to the 10% of the item’s average qty on hand for the past year. Please note that a
  • 6. running average needs to be calculated during the current year and kept for the past year as well). So discuss what triggers needs to be made that will use a function for calculating running avg and maintaining safe levels of the inventory. How would you prepare, in 2016, for this new functionality in order to be ready for 2017 (especially automating end of year processing). Step 9: SUNRISE is considering expanding the DB with INVOICES to old customers (if inventory on hand cannot completely fulfill an order), but will still accept new customers for orders that can be completely fulfilled from on hand inventory. Step 10: To demonstrate value of the newly completed DB design, create four intermediate level SQL queries, not possible with the old QSALE DB design, illustrating interests of various stakeholders (managers, customers, suppliers, and employees). In addition create necessary views to assure that any queries that worked with the original QSALE DB work without changes. Part II problem set (100 points max). Expected effort is 5+ hours. This part will cover exploration of SQL query alternatives for selected problem patterns. You can user both SQL Server and Oracle (in case of differ possible syntax) but to count each query must be true alternative meaning their execution/explain plans must be different. Always inspect data content first to visualize what can be expected. Make sure to test your code and demonstrate validity of each solution!
  • 7. Here the number of correct queries and their originality count towards the grade. Problem #1 (50 points max) – not so easy Given a QDEL table from the (old i.e. original) QSALE DB provide as many alternatives in SQL to select every fifth record. Problem #2 (50 points max) – moderate Given a QITEM table, from the QSALE DB, copy its content into NEWITEM table. Make three unrelated but elementary changes (one record update, one new record insert, and one old record delete) in NEWITEM table. a) Provide as many different ways using SQL (but no stored procedures or triggers) to accomplish the following task: compare the tables QITEM and NEWITEM to assess if they are now exactly the same.