SlideShare a Scribd company logo
1 of 27
HOLMES
INSTITUTE
FACULTY
OF HIGHER
EDUCATION
UNDERGRADUATE
PROGRAM
Page 1 of 14
HS2021 Database Design and Use
Individual Assignment
Version 1
Assignment Value: 15% of your final mark
Due Date/Time: End of week 8 11:59PM (See Blackboard for
submission deadline)
Submission Requirements
• Create a text file that contains all of the statements required
for all tasks of this
assignment.
• Your scripts must work with Oracle Live SQL
• You must submit your assignment via Blackboard submission
link by the due
date. (Note: Late submissions will attract a penalty)
• In week 8 Lab, you may request to demonstrate your
assignment to your tutor.
Make sure that you have a soft copy of the script with you in
the lab.
1. Section 1
A database analyst has developed the following ER Diagram:
Page 2 of 14
Create a script file named ASS1_SQL.TXT
Add your Student ID and Student name the first lines of the
script file.
1.1. Relationships
Write the English sentences that best describe the ERD above.
• Place the text in the specified location in the file:
ASS1_SQL.TXT
• Prefix each line with comment symbols -- (two hyphens)
E.g.: --ONE Employee MUST belong to ONE Branch
--ONE Branch MAY employ to MANY Employees
--ONE Branch MUST belong to ONE Organisation
-- ONE Organisation MAY employ to MANY Branches
1.2.Drop Tables
Write SQL DROP statements that will drop all the tables.
Add these statements to the appropriate location within the
script file.
Page 3 of 14
1.3. Create Tables
Write SQL CREATE TABLE statements to create all the tables.
Add these statements to the appropriate location within the
script file.
Note:
• All tables must have primary keys.
• All tables must have appropriate foreign key constraints.
• Each foreign key column must have identical column name,
data type and size of the
primary key that it refers to
• Add any NOT NULL constraints as dictated by the ERD
• The following columns data types and sizes must be used
custid, prodid, ordid, spid number(4)
cfirstname, csurname, billingaddress,
deliveryaddress, prodname, spfirstname,
spsurname
varchar(30)
cgender, spgender varchar(1)
qtysold, qtydelivered number(4)
saleprice, currentprice number(6,2)
The following constraints must be used
Type Details
Check Gender values must be M or F
Check Prices must be in the range 0 to 5000
Check Quantities must be in the range 0 - 99
Foreign Key All foreign keys must have
named constraints
Page 4 of 14
1.4. Insert Customers
Write SQL INSERT statements that add the data shown to the
CUSTOMER table.
Add these statements to the appropriate location within the
script file.
ID Name Gender Bill Address
1 Casey Cartwright F 1 High St Kew
2 Evan Chambers M 8 Red St Rye
3 Calvin Owens M 7 Long Rd Lara
4 Frannie Morgan F 9 Down Pde Upwey
5 Cappie Jones M 6 Mist St Toorak
6 Dana Stockwell F 2 Tree St Epping
7 Ash Howard F 4 Elm Ave Elwood
1.5. Check constraint error
Write SQL INSERT statements that attempt to add the data
shown to the CUSTOMER table.
This statement must fail due to check constraints.
Add these statements to the appropriate location within the
script file.
ID Name Gender Bill Address
8 Milton Hastings X 3 Blue St, Kew
1.6. Insert Products
Write SQL INSERT statements that add the data shown to the
PRODUCT table.
Add these statements to the appropriate location within the
script file.
ID Name Price
31 Lounge Chair 799
32 Study Lamp 150
33 Large Desk 550
34 Hallway Table 1200
35 Kitchen Stool 220
36 Lamp Stand (Tall) 189
37 Zzz King Size Single Bed 400
38 Bedside Lamp 99
39 Coffee Table 650
Page 5 of 14
1.7. Check constraint error
Write SQL INSERT statements that attempt to add the data
shown to the PRODUCT table.
This statement must fail due to check constraints. Add these
statements to the appropriate
location within the script file.
ID Name Price
40 Cupboard -99
41 Bookcase 8765
1.8. Insert Salespersons
Write SQL INSERT statements that add the data shown to the
SALESPERSON table. Add
these statements to the appropriate location within the script
file.
ID Name Gender
21 Serena Van der Woodsen F
22 Dan Humphrey M
23 Blair Waldorf F
24 Chuck Bass M
25 Lily Van der Woodsen F
26 Nate Archibald M
1.9. Insert Shop Orders
Write SQL INSERT statements that add the data shown to the
SHOPORDER table.
Add these statements to the appropriate location within the
script file.
Customer 1 Orders:
ORDID DELIVERADDRESS SALESPERSON
41 NULL 23
51 NULL 23
Customer 2 Orders:
ORDID DELIVERADDRESS SALESPERSON
42 NULL 21
43 NULL 23
49 NULL 24
Page 6 of 14
Customer 3 Orders:
ORDID DELIVERADDRESS SALESPERSON
44 1 John St Hawthorn 26
48 NULL 26
Customer 4 Orders:
ORDID DELIVERADDRESS SALESPERSON
45 1254 Dunstall Rd Coorparoo 22
47 727 Hudson Rd Glenorchy 26
50 517 Franklin St Dowerin 22
Customer 6 Orders:
ORDID DELIVERADDRESS SALESPERSON
46 NULL 21
1.10. FK Error
Write these SQL INSERT statements that attempts to add the
data shown to the SHOPORDER
table. These statements must fail. If they don't fail, there is a
problem with your Foreign Key
constraint clause in your Create Table statement. Add these
statements to the appropriate
location within the script file.
Customer 5 Orders:
ORDID DELIVERADDRESS SALESPERSON
66 NULL 29
Customer 9 Orders:
ORDID DELIVERADDRESS SALESPERSON
67 NULL 26
1.11. Insert Oder Lines
Write SQL INSERT statements that add the data shown to the
ORDERLINE table. Add these
statements to the appropriate location within the script file.
Page 7 of 14
Order 41:
PRODID QTYSOLD QTYDELIVERED SALESPRICE
31 2 0 750
36 1 0 170
Order 42:
PRODID QTYSOLD QTYDELIVERED SALESPRICE
33 1 1 500
Order 43:
PRODID QTYSOLD QTYDELIVERED SALESPRICE
35 6 5 220
Order 44:
PRODID QTYSOLD QTYDELIVERED SALESPRICE
31 1 0 760
34 1 0 1100
36 1 0 180
Order 45:
PRODID QTYSOLD QTYDELIVERED SALESPRICE
36 2 2 175
Order 46:
PRODID QTYSOLD QTYDELIVERED SALESPRICE
37 2 2 380
38 2 2 90
Page 8 of 14
Order 47:
PRODID QTYSOLD QTYDELIVERED SALESPRICE
39 1 0 600
35 1 0 200
36 2 0 175
38 1 0 85
Order 48:
PRODID QTYSOLD QTYDELIVERED SALESPRICE
34 1 1 1200
Order 49:
PRODID QTYSOLD QTYDELIVERED SALESPRICE
38 1 1 90
Order 50:
PRODID QTYSOLD QTYDELIVERED SALESPRICE
31 2 0 750
36 1 0 180
Order 51:
PRODID QTYSOLD QTYDELIVERED SALESPRICE
35 10 10 190
1.12. FK errors
Write these SQL INSERT statements that attempt to add the
data shown to the ORDERLINE
table. These statements must fail. If they don't fail, there is a
problem with your Foreign Key
constraint clause in your Create Table statement. Add these
statements to the appropriate
location within the script file.
Order 49:
PRODID QTYSOLD QTYDELIVERED SALESPRICE
40 2 2 200
Page 9 of 14
Order 52:
PRODID QTYSOLD QTYDELIVERED SALESPRICE
36 10 10 175
1.13. List rows in all Tables
Write five SQL statements that will list all of the rows in all
tables in ascending primary key
sequence. Add these statements to the appropriate location
within the script file.
2. Section 2
Add each statement to the appropriate location within the script
file.
2.1.1 Count the total number of orders in the SHOPORDER
table.
2.1.2 Count the total number of orders that have been made by
female customers.
2.1.3 Count the total number of orders that have been made by
each gender of customer.
2.1.4 List the order id, customer id, firstname & surname for all
shop orders where the
customer is female. List in ascending customer id / order id
sequence
2.1.5 List order id, customer id, firstname & surname, product
id and quantity sold for all
rows in the ORDERLINE table. List in ascending customer id /
order id / product id
sequence.
Page 10 of 14
3. Section 3
The database analyst has modified the existing ER Diagram:
Each product is assigned to one or more managers.
It is the responsibility of a manager to perform a quality check
once a week on each product
that they have been assigned to.
For each quality check performed by a manager, the week no
and score (a value between 1 and
3) is recorded.
3.1.Drop Tables
Write SQL DROP statements that will drop all the additional
tables. Add these statements to
section 1.2 of the script file.
3.2. Create Tables
Write SQL CREATE TABLE statements to create all additional
the tables. Add these statements
to the appropriate location within the script file.
Page 11 of 14
Note:
• All tables must have primary keys.
• All tables must have appropriate foreign key constraints.
• Each foreign key column must have identical column name,
data type and size of the
primary key that it refers to
• Add any NOT NULL constraints as dictated by the ERD
• Choose your own appropriate column data types and sizes
3.3. Insert Managers
Write SQL INSERT statements that add the data shown to the
MANAGER table.
Add these statements to the appropriate location within the
script file.
ID Firstname Surname
101 Bob Starkie
102 Shirley Strachan
103 Greg Macainch
3.4. Insert Allocations
Write SQL INSERT statements for the ALLOCATION table to
assign products to managers.
Add these statements to the appropriate location within the
script file.
Product ID ManagerID
31 101
32 102
32 103
33 103
34 103
35 102
36 101
36 102
Page 12 of 14
3.5. PK Error
Write these SQL INSERT statements that attempt to add the
data shown to the ALLOCATION
table. These statements must fail. If they don't fail, there is a
problem with your Primary Key
constraint clause in your Create Table statement. Add these
statements to the appropriate
location within the script file.
Product ID ManagerID
35 102
36 101
3.6. Insert Quality Checks
Write SQL INSERT statements for the QUALITYCHECK table
to record scores awarded by
managers. Add these statements to the appropriate location
within the script file.
Product ID ManagerID Week Number Score
31 101 1 3
31 101 2 2
31 101 3 3
32 102 1 1
32 102 2 2
32 102 3 1
32 103 1 2
32 103 2 1
32 103 3 1
33 103 1 1
33 103 2 3
33 103 3 3
3.7. PK Error
Write these SQL INSERT statements that attempt to add the
data shown to the
QUALITYCHECK table. These statements must fail. If they
don't fail, there is a problem with
your Primary Key constraint clause in your Create Table
statement. Add these statements to the
appropriate location within the script file.
Product ID ManagerID Week Number Score
31 101 3 3
32 102 1 1
Page 13 of 14
3.8. FK Error
Write these SQL INSERT statements that attempt to add the
data shown to the
QUALITYCHECK table. These statements must fail. If they
don't fail, there is a problem with
your Foreign Key constraint clause in your Create Table
statement. Add these statements to the
appropriate location within the script file.
Product ID ManagerID Week Number Score
31 101 1 2
34 101 1 3
36 103 2 2
31 102 3 3
32 101 1 1
3.9. List all rows in additional Tables
Write three SQL statements that will list all of the rows from all
additional tables in ascending
primary key sequence. Add these statements to the appropriate
location within the script file.
4. Section 4:
Write these SQL SELECT statements.
Add each statement to the appropriate location within the script
file.
4.1. List the order id, product id, product name, current price,
sale price and the price difference
for all products that appear in the ORDERLINE table. Only list
rows where the price
difference is greater than 10% of the product's current selling
price. List in ascending
price difference sequence.
4.2. Use a Union clause to list the names of all customers,
salespersons and managers in surname
/ firstname sequence. Show the role of each person.
4.3. Use a UNION clause to list each order id and address. The
list must be in ascending Order
ID sequence. If the Shop Order delivery address is NULL, then
you must display the
customer's billing address instead of the delivery address.
4.4. List the order id, customer id, firstname & surname,
product id & name for all rows in the
ORDERLINE table. List in ascending customer id / order id /
product id sequence.
4.5. List the product id, name and current price of all products
that have a selling price greater
the average current price of all products. List in ascending
current price sequence
Page 14 of 14
5. Section 5:
5.1. For each row in the SHOPORDER table, show the customer
id & surname and order id.
Ensure that every customer is the CUSTOMER table is listed –
even if they have not created
any shop orders. List in ascending customer id / order id
sequence.
5.2. Count the number of shop orders for each customer. Ensure
that every customer is the
CUSTOMER table is listed – even if they have not created any
shop orders. List in ascending
customer id.
5.3. List order id, customer id, firstname & surname, product id
and quantity sold for all rows in
the ORDERLINE table. List in ascending customer id / order id
/ product id sequence.
5.4. List the product id, product name and total quantity sold for
all products that appear in the
ORDERLINE table. List in ascending total sequence / product
id.
5.5. Same as above, but only show products where total sales
are in the range 2 to 10 (inclusive)
5.6. Same as above, but only show products where total sales
are greater than 1 that contain the
word 'Lamp' or 'Table' in the product name.
5.7. List the average score in the QUALITY CHECK table for
each product. Only show results
if the average score is greater than or equal to 2.0. List an
ascending average score sequence.
5.8. List the total orders for products with an average quality
check score greater than or equal to
2.0. Do not 'hard code' product ids 33 and 31 in your query as
obviously data values will
change over time.
- End of assignment -
HOLMES  INSTITUTE    FACULTY  OF HIGHER  EDUCATION.docx

More Related Content

Similar to HOLMES INSTITUTE FACULTY OF HIGHER EDUCATION.docx

Project 2InstructionsIn this project you will perform.docx
Project 2InstructionsIn this project you will perform.docxProject 2InstructionsIn this project you will perform.docx
Project 2InstructionsIn this project you will perform.docxwkyra78
 
Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...
Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...
Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...KarenMiner
 
Advanced integration services on microsoft ssis 1
Advanced integration services on microsoft ssis 1Advanced integration services on microsoft ssis 1
Advanced integration services on microsoft ssis 1Skillwise Group
 
BUSI 301 Book Review RubricScoreCommentsResearch 25.docx
BUSI 301 Book Review RubricScoreCommentsResearch 25.docxBUSI 301 Book Review RubricScoreCommentsResearch 25.docx
BUSI 301 Book Review RubricScoreCommentsResearch 25.docxhumphrieskalyn
 
CIS 336 STUDY Introduction Education--cis336study.com
CIS 336 STUDY Introduction Education--cis336study.comCIS 336 STUDY Introduction Education--cis336study.com
CIS 336 STUDY Introduction Education--cis336study.comclaric262
 
ADBMS ASSIGNMENT
ADBMS ASSIGNMENTADBMS ASSIGNMENT
ADBMS ASSIGNMENTLori Moore
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfoliokarlumaguing
 
1Z0-061 Oracle Database 12c: SQL Fundamentals
1Z0-061 Oracle Database 12c: SQL Fundamentals1Z0-061 Oracle Database 12c: SQL Fundamentals
1Z0-061 Oracle Database 12c: SQL FundamentalsLydi00147
 
Warranty management system
Warranty management systemWarranty management system
Warranty management systemMoin Raza Khan
 
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
 
Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3Massimo Cenci
 
SQL Practice Question set
SQL Practice Question set SQL Practice Question set
SQL Practice Question set Mohd Tousif
 

Similar to HOLMES INSTITUTE FACULTY OF HIGHER EDUCATION.docx (20)

1 z0 047
1 z0 0471 z0 047
1 z0 047
 
SQL
SQLSQL
SQL
 
Project 2InstructionsIn this project you will perform.docx
Project 2InstructionsIn this project you will perform.docxProject 2InstructionsIn this project you will perform.docx
Project 2InstructionsIn this project you will perform.docx
 
Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...
Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...
Solved Practice questions for Microsoft Querying Data with Transact-SQL 70-76...
 
Bis 345-week-4-i lab-new
Bis 345-week-4-i lab-newBis 345-week-4-i lab-new
Bis 345-week-4-i lab-new
 
Physical Design and Development
Physical Design and DevelopmentPhysical Design and Development
Physical Design and Development
 
Advanced integration services on microsoft ssis 1
Advanced integration services on microsoft ssis 1Advanced integration services on microsoft ssis 1
Advanced integration services on microsoft ssis 1
 
BUSI 301 Book Review RubricScoreCommentsResearch 25.docx
BUSI 301 Book Review RubricScoreCommentsResearch 25.docxBUSI 301 Book Review RubricScoreCommentsResearch 25.docx
BUSI 301 Book Review RubricScoreCommentsResearch 25.docx
 
CIS 336 STUDY Introduction Education--cis336study.com
CIS 336 STUDY Introduction Education--cis336study.comCIS 336 STUDY Introduction Education--cis336study.com
CIS 336 STUDY Introduction Education--cis336study.com
 
ADBMS ASSIGNMENT
ADBMS ASSIGNMENTADBMS ASSIGNMENT
ADBMS ASSIGNMENT
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
1Z0-061 Oracle Database 12c: SQL Fundamentals
1Z0-061 Oracle Database 12c: SQL Fundamentals1Z0-061 Oracle Database 12c: SQL Fundamentals
1Z0-061 Oracle Database 12c: SQL Fundamentals
 
Warranty management system
Warranty management systemWarranty management system
Warranty management system
 
Database Management System - SQL beginner Training
Database Management System - SQL beginner Training Database Management System - SQL beginner Training
Database Management System - SQL beginner Training
 
Sql ch 5
Sql ch 5Sql ch 5
Sql ch 5
 
Sql
SqlSql
Sql
 
Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3
 
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
 
Dbms practical list
Dbms practical listDbms practical list
Dbms practical list
 
SQL Practice Question set
SQL Practice Question set SQL Practice Question set
SQL Practice Question set
 

More from simonithomas47935

Hours, A. (2014). Reading Fairy Tales and Playing A Way of Treati.docx
Hours, A. (2014). Reading Fairy Tales and Playing A Way of Treati.docxHours, A. (2014). Reading Fairy Tales and Playing A Way of Treati.docx
Hours, A. (2014). Reading Fairy Tales and Playing A Way of Treati.docxsimonithomas47935
 
How are authentication and authorization alike and how are the.docx
How are authentication and authorization alike and how are the.docxHow are authentication and authorization alike and how are the.docx
How are authentication and authorization alike and how are the.docxsimonithomas47935
 
How are self-esteem and self-concept different What is the or.docx
How are self-esteem and self-concept different What is the or.docxHow are self-esteem and self-concept different What is the or.docx
How are self-esteem and self-concept different What is the or.docxsimonithomas47935
 
How are morality and religion similar and how are they different.docx
How are morality and religion similar and how are they different.docxHow are morality and religion similar and how are they different.docx
How are morality and religion similar and how are they different.docxsimonithomas47935
 
How are financial statements used to evaluate business activities.docx
How are financial statements used to evaluate business activities.docxHow are financial statements used to evaluate business activities.docx
How are financial statements used to evaluate business activities.docxsimonithomas47935
 
How are Japanese and Chinese Americans similar How are they differe.docx
How are Japanese and Chinese Americans similar How are they differe.docxHow are Japanese and Chinese Americans similar How are they differe.docx
How are Japanese and Chinese Americans similar How are they differe.docxsimonithomas47935
 
Hot Spot PolicingPlace can be an important aspect of crime and.docx
Hot Spot PolicingPlace can be an important aspect of crime and.docxHot Spot PolicingPlace can be an important aspect of crime and.docx
Hot Spot PolicingPlace can be an important aspect of crime and.docxsimonithomas47935
 
HOSP3075 Brand Analysis Paper 1This is the first of three assignme.docx
HOSP3075 Brand Analysis Paper 1This is the first of three assignme.docxHOSP3075 Brand Analysis Paper 1This is the first of three assignme.docx
HOSP3075 Brand Analysis Paper 1This is the first of three assignme.docxsimonithomas47935
 
Hou, J., Li, Y., Yu, J. & Shi, W. (2020). A Survey on Digital Fo.docx
Hou, J., Li, Y., Yu, J. & Shi, W. (2020). A Survey on Digital Fo.docxHou, J., Li, Y., Yu, J. & Shi, W. (2020). A Survey on Digital Fo.docx
Hou, J., Li, Y., Yu, J. & Shi, W. (2020). A Survey on Digital Fo.docxsimonithomas47935
 
How (Not) to be Secular by James K.A. SmithSecular (1)—the ea.docx
How (Not) to be Secular by James K.A. SmithSecular (1)—the ea.docxHow (Not) to be Secular by James K.A. SmithSecular (1)—the ea.docx
How (Not) to be Secular by James K.A. SmithSecular (1)—the ea.docxsimonithomas47935
 
Hopefully, you enjoyed this class on Digital Media and Society.Q.docx
Hopefully, you enjoyed this class on Digital Media and Society.Q.docxHopefully, you enjoyed this class on Digital Media and Society.Q.docx
Hopefully, you enjoyed this class on Digital Media and Society.Q.docxsimonithomas47935
 
hoose (1) one childhood experience from the list provided below..docx
hoose (1) one childhood experience from the list provided below..docxhoose (1) one childhood experience from the list provided below..docx
hoose (1) one childhood experience from the list provided below..docxsimonithomas47935
 
honesty, hard work, caring, excellence HIS 1110 Dr. .docx
honesty, hard work, caring, excellence  HIS 1110      Dr. .docxhonesty, hard work, caring, excellence  HIS 1110      Dr. .docx
honesty, hard work, caring, excellence HIS 1110 Dr. .docxsimonithomas47935
 
hoose one of the four following visualsImage courtesy o.docx
hoose one of the four following visualsImage courtesy o.docxhoose one of the four following visualsImage courtesy o.docx
hoose one of the four following visualsImage courtesy o.docxsimonithomas47935
 
HomeworkChoose a site used by the public such as a supermark.docx
HomeworkChoose a site used by the public such as a supermark.docxHomeworkChoose a site used by the public such as a supermark.docx
HomeworkChoose a site used by the public such as a supermark.docxsimonithomas47935
 
Homework 2 Please answer the following questions in small paragraph.docx
Homework 2 Please answer the following questions in small paragraph.docxHomework 2 Please answer the following questions in small paragraph.docx
Homework 2 Please answer the following questions in small paragraph.docxsimonithomas47935
 
HomeNotificationsMy CommunityBBA 2010-16J-5A21-S1, Introductio.docx
HomeNotificationsMy CommunityBBA 2010-16J-5A21-S1, Introductio.docxHomeNotificationsMy CommunityBBA 2010-16J-5A21-S1, Introductio.docx
HomeNotificationsMy CommunityBBA 2010-16J-5A21-S1, Introductio.docxsimonithomas47935
 
HomeAnnouncementsSyllabusDiscussionsQuizzesGra.docx
HomeAnnouncementsSyllabusDiscussionsQuizzesGra.docxHomeAnnouncementsSyllabusDiscussionsQuizzesGra.docx
HomeAnnouncementsSyllabusDiscussionsQuizzesGra.docxsimonithomas47935
 
Homeless The Motel Kids of Orange CountyWrite a 1-2 page pa.docx
Homeless The Motel Kids of Orange CountyWrite a 1-2 page pa.docxHomeless The Motel Kids of Orange CountyWrite a 1-2 page pa.docx
Homeless The Motel Kids of Orange CountyWrite a 1-2 page pa.docxsimonithomas47935
 
Home work 8 Date 042220201. what are the different between.docx
Home work  8 Date 042220201. what are the  different between.docxHome work  8 Date 042220201. what are the  different between.docx
Home work 8 Date 042220201. what are the different between.docxsimonithomas47935
 

More from simonithomas47935 (20)

Hours, A. (2014). Reading Fairy Tales and Playing A Way of Treati.docx
Hours, A. (2014). Reading Fairy Tales and Playing A Way of Treati.docxHours, A. (2014). Reading Fairy Tales and Playing A Way of Treati.docx
Hours, A. (2014). Reading Fairy Tales and Playing A Way of Treati.docx
 
How are authentication and authorization alike and how are the.docx
How are authentication and authorization alike and how are the.docxHow are authentication and authorization alike and how are the.docx
How are authentication and authorization alike and how are the.docx
 
How are self-esteem and self-concept different What is the or.docx
How are self-esteem and self-concept different What is the or.docxHow are self-esteem and self-concept different What is the or.docx
How are self-esteem and self-concept different What is the or.docx
 
How are morality and religion similar and how are they different.docx
How are morality and religion similar and how are they different.docxHow are morality and religion similar and how are they different.docx
How are morality and religion similar and how are they different.docx
 
How are financial statements used to evaluate business activities.docx
How are financial statements used to evaluate business activities.docxHow are financial statements used to evaluate business activities.docx
How are financial statements used to evaluate business activities.docx
 
How are Japanese and Chinese Americans similar How are they differe.docx
How are Japanese and Chinese Americans similar How are they differe.docxHow are Japanese and Chinese Americans similar How are they differe.docx
How are Japanese and Chinese Americans similar How are they differe.docx
 
Hot Spot PolicingPlace can be an important aspect of crime and.docx
Hot Spot PolicingPlace can be an important aspect of crime and.docxHot Spot PolicingPlace can be an important aspect of crime and.docx
Hot Spot PolicingPlace can be an important aspect of crime and.docx
 
HOSP3075 Brand Analysis Paper 1This is the first of three assignme.docx
HOSP3075 Brand Analysis Paper 1This is the first of three assignme.docxHOSP3075 Brand Analysis Paper 1This is the first of three assignme.docx
HOSP3075 Brand Analysis Paper 1This is the first of three assignme.docx
 
Hou, J., Li, Y., Yu, J. & Shi, W. (2020). A Survey on Digital Fo.docx
Hou, J., Li, Y., Yu, J. & Shi, W. (2020). A Survey on Digital Fo.docxHou, J., Li, Y., Yu, J. & Shi, W. (2020). A Survey on Digital Fo.docx
Hou, J., Li, Y., Yu, J. & Shi, W. (2020). A Survey on Digital Fo.docx
 
How (Not) to be Secular by James K.A. SmithSecular (1)—the ea.docx
How (Not) to be Secular by James K.A. SmithSecular (1)—the ea.docxHow (Not) to be Secular by James K.A. SmithSecular (1)—the ea.docx
How (Not) to be Secular by James K.A. SmithSecular (1)—the ea.docx
 
Hopefully, you enjoyed this class on Digital Media and Society.Q.docx
Hopefully, you enjoyed this class on Digital Media and Society.Q.docxHopefully, you enjoyed this class on Digital Media and Society.Q.docx
Hopefully, you enjoyed this class on Digital Media and Society.Q.docx
 
hoose (1) one childhood experience from the list provided below..docx
hoose (1) one childhood experience from the list provided below..docxhoose (1) one childhood experience from the list provided below..docx
hoose (1) one childhood experience from the list provided below..docx
 
honesty, hard work, caring, excellence HIS 1110 Dr. .docx
honesty, hard work, caring, excellence  HIS 1110      Dr. .docxhonesty, hard work, caring, excellence  HIS 1110      Dr. .docx
honesty, hard work, caring, excellence HIS 1110 Dr. .docx
 
hoose one of the four following visualsImage courtesy o.docx
hoose one of the four following visualsImage courtesy o.docxhoose one of the four following visualsImage courtesy o.docx
hoose one of the four following visualsImage courtesy o.docx
 
HomeworkChoose a site used by the public such as a supermark.docx
HomeworkChoose a site used by the public such as a supermark.docxHomeworkChoose a site used by the public such as a supermark.docx
HomeworkChoose a site used by the public such as a supermark.docx
 
Homework 2 Please answer the following questions in small paragraph.docx
Homework 2 Please answer the following questions in small paragraph.docxHomework 2 Please answer the following questions in small paragraph.docx
Homework 2 Please answer the following questions in small paragraph.docx
 
HomeNotificationsMy CommunityBBA 2010-16J-5A21-S1, Introductio.docx
HomeNotificationsMy CommunityBBA 2010-16J-5A21-S1, Introductio.docxHomeNotificationsMy CommunityBBA 2010-16J-5A21-S1, Introductio.docx
HomeNotificationsMy CommunityBBA 2010-16J-5A21-S1, Introductio.docx
 
HomeAnnouncementsSyllabusDiscussionsQuizzesGra.docx
HomeAnnouncementsSyllabusDiscussionsQuizzesGra.docxHomeAnnouncementsSyllabusDiscussionsQuizzesGra.docx
HomeAnnouncementsSyllabusDiscussionsQuizzesGra.docx
 
Homeless The Motel Kids of Orange CountyWrite a 1-2 page pa.docx
Homeless The Motel Kids of Orange CountyWrite a 1-2 page pa.docxHomeless The Motel Kids of Orange CountyWrite a 1-2 page pa.docx
Homeless The Motel Kids of Orange CountyWrite a 1-2 page pa.docx
 
Home work 8 Date 042220201. what are the different between.docx
Home work  8 Date 042220201. what are the  different between.docxHome work  8 Date 042220201. what are the  different between.docx
Home work 8 Date 042220201. what are the different between.docx
 

Recently uploaded

On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 

Recently uploaded (20)

On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 

HOLMES INSTITUTE FACULTY OF HIGHER EDUCATION.docx

  • 1. HOLMES INSTITUTE FACULTY OF HIGHER EDUCATION UNDERGRADUATE PROGRAM Page 1 of 14 HS2021 Database Design and Use Individual Assignment Version 1 Assignment Value: 15% of your final mark Due Date/Time: End of week 8 11:59PM (See Blackboard for submission deadline)
  • 2. Submission Requirements • Create a text file that contains all of the statements required for all tasks of this assignment. • Your scripts must work with Oracle Live SQL • You must submit your assignment via Blackboard submission link by the due date. (Note: Late submissions will attract a penalty) • In week 8 Lab, you may request to demonstrate your assignment to your tutor. Make sure that you have a soft copy of the script with you in the lab. 1. Section 1 A database analyst has developed the following ER Diagram: Page 2 of 14
  • 3. Create a script file named ASS1_SQL.TXT Add your Student ID and Student name the first lines of the script file. 1.1. Relationships Write the English sentences that best describe the ERD above. • Place the text in the specified location in the file: ASS1_SQL.TXT • Prefix each line with comment symbols -- (two hyphens) E.g.: --ONE Employee MUST belong to ONE Branch --ONE Branch MAY employ to MANY Employees --ONE Branch MUST belong to ONE Organisation -- ONE Organisation MAY employ to MANY Branches 1.2.Drop Tables Write SQL DROP statements that will drop all the tables. Add these statements to the appropriate location within the script file.
  • 4. Page 3 of 14 1.3. Create Tables Write SQL CREATE TABLE statements to create all the tables. Add these statements to the appropriate location within the script file. Note: • All tables must have primary keys. • All tables must have appropriate foreign key constraints. • Each foreign key column must have identical column name, data type and size of the primary key that it refers to • Add any NOT NULL constraints as dictated by the ERD • The following columns data types and sizes must be used custid, prodid, ordid, spid number(4) cfirstname, csurname, billingaddress, deliveryaddress, prodname, spfirstname, spsurname varchar(30)
  • 5. cgender, spgender varchar(1) qtysold, qtydelivered number(4) saleprice, currentprice number(6,2) The following constraints must be used Type Details Check Gender values must be M or F Check Prices must be in the range 0 to 5000 Check Quantities must be in the range 0 - 99 Foreign Key All foreign keys must have named constraints Page 4 of 14
  • 6. 1.4. Insert Customers Write SQL INSERT statements that add the data shown to the CUSTOMER table. Add these statements to the appropriate location within the script file. ID Name Gender Bill Address 1 Casey Cartwright F 1 High St Kew 2 Evan Chambers M 8 Red St Rye 3 Calvin Owens M 7 Long Rd Lara 4 Frannie Morgan F 9 Down Pde Upwey 5 Cappie Jones M 6 Mist St Toorak 6 Dana Stockwell F 2 Tree St Epping 7 Ash Howard F 4 Elm Ave Elwood 1.5. Check constraint error Write SQL INSERT statements that attempt to add the data shown to the CUSTOMER table. This statement must fail due to check constraints. Add these statements to the appropriate location within the script file. ID Name Gender Bill Address
  • 7. 8 Milton Hastings X 3 Blue St, Kew 1.6. Insert Products Write SQL INSERT statements that add the data shown to the PRODUCT table. Add these statements to the appropriate location within the script file. ID Name Price 31 Lounge Chair 799 32 Study Lamp 150 33 Large Desk 550 34 Hallway Table 1200 35 Kitchen Stool 220 36 Lamp Stand (Tall) 189 37 Zzz King Size Single Bed 400 38 Bedside Lamp 99 39 Coffee Table 650 Page 5 of 14
  • 8. 1.7. Check constraint error Write SQL INSERT statements that attempt to add the data shown to the PRODUCT table. This statement must fail due to check constraints. Add these statements to the appropriate location within the script file. ID Name Price 40 Cupboard -99 41 Bookcase 8765 1.8. Insert Salespersons Write SQL INSERT statements that add the data shown to the SALESPERSON table. Add these statements to the appropriate location within the script file. ID Name Gender 21 Serena Van der Woodsen F 22 Dan Humphrey M 23 Blair Waldorf F 24 Chuck Bass M
  • 9. 25 Lily Van der Woodsen F 26 Nate Archibald M 1.9. Insert Shop Orders Write SQL INSERT statements that add the data shown to the SHOPORDER table. Add these statements to the appropriate location within the script file. Customer 1 Orders: ORDID DELIVERADDRESS SALESPERSON 41 NULL 23 51 NULL 23 Customer 2 Orders: ORDID DELIVERADDRESS SALESPERSON 42 NULL 21 43 NULL 23 49 NULL 24
  • 10. Page 6 of 14 Customer 3 Orders: ORDID DELIVERADDRESS SALESPERSON 44 1 John St Hawthorn 26 48 NULL 26 Customer 4 Orders: ORDID DELIVERADDRESS SALESPERSON 45 1254 Dunstall Rd Coorparoo 22 47 727 Hudson Rd Glenorchy 26 50 517 Franklin St Dowerin 22 Customer 6 Orders: ORDID DELIVERADDRESS SALESPERSON 46 NULL 21 1.10. FK Error Write these SQL INSERT statements that attempts to add the data shown to the SHOPORDER
  • 11. table. These statements must fail. If they don't fail, there is a problem with your Foreign Key constraint clause in your Create Table statement. Add these statements to the appropriate location within the script file. Customer 5 Orders: ORDID DELIVERADDRESS SALESPERSON 66 NULL 29 Customer 9 Orders: ORDID DELIVERADDRESS SALESPERSON 67 NULL 26 1.11. Insert Oder Lines Write SQL INSERT statements that add the data shown to the ORDERLINE table. Add these statements to the appropriate location within the script file.
  • 12. Page 7 of 14 Order 41: PRODID QTYSOLD QTYDELIVERED SALESPRICE 31 2 0 750 36 1 0 170 Order 42: PRODID QTYSOLD QTYDELIVERED SALESPRICE 33 1 1 500 Order 43: PRODID QTYSOLD QTYDELIVERED SALESPRICE 35 6 5 220 Order 44: PRODID QTYSOLD QTYDELIVERED SALESPRICE 31 1 0 760 34 1 0 1100 36 1 0 180
  • 13. Order 45: PRODID QTYSOLD QTYDELIVERED SALESPRICE 36 2 2 175 Order 46: PRODID QTYSOLD QTYDELIVERED SALESPRICE 37 2 2 380 38 2 2 90 Page 8 of 14 Order 47: PRODID QTYSOLD QTYDELIVERED SALESPRICE 39 1 0 600
  • 14. 35 1 0 200 36 2 0 175 38 1 0 85 Order 48: PRODID QTYSOLD QTYDELIVERED SALESPRICE 34 1 1 1200 Order 49: PRODID QTYSOLD QTYDELIVERED SALESPRICE 38 1 1 90 Order 50: PRODID QTYSOLD QTYDELIVERED SALESPRICE 31 2 0 750 36 1 0 180 Order 51: PRODID QTYSOLD QTYDELIVERED SALESPRICE
  • 15. 35 10 10 190 1.12. FK errors Write these SQL INSERT statements that attempt to add the data shown to the ORDERLINE table. These statements must fail. If they don't fail, there is a problem with your Foreign Key constraint clause in your Create Table statement. Add these statements to the appropriate location within the script file. Order 49: PRODID QTYSOLD QTYDELIVERED SALESPRICE 40 2 2 200 Page 9 of 14 Order 52: PRODID QTYSOLD QTYDELIVERED SALESPRICE 36 10 10 175
  • 16. 1.13. List rows in all Tables Write five SQL statements that will list all of the rows in all tables in ascending primary key sequence. Add these statements to the appropriate location within the script file. 2. Section 2 Add each statement to the appropriate location within the script file. 2.1.1 Count the total number of orders in the SHOPORDER table. 2.1.2 Count the total number of orders that have been made by female customers. 2.1.3 Count the total number of orders that have been made by each gender of customer. 2.1.4 List the order id, customer id, firstname & surname for all shop orders where the customer is female. List in ascending customer id / order id sequence 2.1.5 List order id, customer id, firstname & surname, product id and quantity sold for all rows in the ORDERLINE table. List in ascending customer id / order id / product id sequence.
  • 17. Page 10 of 14 3. Section 3 The database analyst has modified the existing ER Diagram: Each product is assigned to one or more managers. It is the responsibility of a manager to perform a quality check once a week on each product
  • 18. that they have been assigned to. For each quality check performed by a manager, the week no and score (a value between 1 and 3) is recorded. 3.1.Drop Tables Write SQL DROP statements that will drop all the additional tables. Add these statements to section 1.2 of the script file. 3.2. Create Tables Write SQL CREATE TABLE statements to create all additional the tables. Add these statements to the appropriate location within the script file. Page 11 of 14 Note: • All tables must have primary keys.
  • 19. • All tables must have appropriate foreign key constraints. • Each foreign key column must have identical column name, data type and size of the primary key that it refers to • Add any NOT NULL constraints as dictated by the ERD • Choose your own appropriate column data types and sizes 3.3. Insert Managers Write SQL INSERT statements that add the data shown to the MANAGER table. Add these statements to the appropriate location within the script file. ID Firstname Surname 101 Bob Starkie 102 Shirley Strachan 103 Greg Macainch 3.4. Insert Allocations Write SQL INSERT statements for the ALLOCATION table to assign products to managers. Add these statements to the appropriate location within the script file.
  • 20. Product ID ManagerID 31 101 32 102 32 103 33 103 34 103 35 102 36 101 36 102 Page 12 of 14 3.5. PK Error Write these SQL INSERT statements that attempt to add the data shown to the ALLOCATION table. These statements must fail. If they don't fail, there is a problem with your Primary Key
  • 21. constraint clause in your Create Table statement. Add these statements to the appropriate location within the script file. Product ID ManagerID 35 102 36 101 3.6. Insert Quality Checks Write SQL INSERT statements for the QUALITYCHECK table to record scores awarded by managers. Add these statements to the appropriate location within the script file. Product ID ManagerID Week Number Score 31 101 1 3 31 101 2 2 31 101 3 3 32 102 1 1 32 102 2 2 32 102 3 1 32 103 1 2
  • 22. 32 103 2 1 32 103 3 1 33 103 1 1 33 103 2 3 33 103 3 3 3.7. PK Error Write these SQL INSERT statements that attempt to add the data shown to the QUALITYCHECK table. These statements must fail. If they don't fail, there is a problem with your Primary Key constraint clause in your Create Table statement. Add these statements to the appropriate location within the script file. Product ID ManagerID Week Number Score 31 101 3 3 32 102 1 1 Page 13 of 14
  • 23. 3.8. FK Error Write these SQL INSERT statements that attempt to add the data shown to the QUALITYCHECK table. These statements must fail. If they don't fail, there is a problem with your Foreign Key constraint clause in your Create Table statement. Add these statements to the appropriate location within the script file. Product ID ManagerID Week Number Score 31 101 1 2 34 101 1 3 36 103 2 2 31 102 3 3 32 101 1 1 3.9. List all rows in additional Tables Write three SQL statements that will list all of the rows from all additional tables in ascending primary key sequence. Add these statements to the appropriate location within the script file. 4. Section 4:
  • 24. Write these SQL SELECT statements. Add each statement to the appropriate location within the script file. 4.1. List the order id, product id, product name, current price, sale price and the price difference for all products that appear in the ORDERLINE table. Only list rows where the price difference is greater than 10% of the product's current selling price. List in ascending price difference sequence. 4.2. Use a Union clause to list the names of all customers, salespersons and managers in surname / firstname sequence. Show the role of each person. 4.3. Use a UNION clause to list each order id and address. The list must be in ascending Order ID sequence. If the Shop Order delivery address is NULL, then you must display the customer's billing address instead of the delivery address. 4.4. List the order id, customer id, firstname & surname, product id & name for all rows in the ORDERLINE table. List in ascending customer id / order id / product id sequence. 4.5. List the product id, name and current price of all products
  • 25. that have a selling price greater the average current price of all products. List in ascending current price sequence Page 14 of 14 5. Section 5: 5.1. For each row in the SHOPORDER table, show the customer id & surname and order id. Ensure that every customer is the CUSTOMER table is listed – even if they have not created any shop orders. List in ascending customer id / order id sequence. 5.2. Count the number of shop orders for each customer. Ensure that every customer is the CUSTOMER table is listed – even if they have not created any shop orders. List in ascending customer id. 5.3. List order id, customer id, firstname & surname, product id and quantity sold for all rows in
  • 26. the ORDERLINE table. List in ascending customer id / order id / product id sequence. 5.4. List the product id, product name and total quantity sold for all products that appear in the ORDERLINE table. List in ascending total sequence / product id. 5.5. Same as above, but only show products where total sales are in the range 2 to 10 (inclusive) 5.6. Same as above, but only show products where total sales are greater than 1 that contain the word 'Lamp' or 'Table' in the product name. 5.7. List the average score in the QUALITY CHECK table for each product. Only show results if the average score is greater than or equal to 2.0. List an ascending average score sequence. 5.8. List the total orders for products with an average quality check score greater than or equal to 2.0. Do not 'hard code' product ids 33 and 31 in your query as obviously data values will change over time. - End of assignment -