Assignment Number 1 -Answers
-
Upload
rohit-shetty -
Category
Documents
-
view
44 -
download
8
description
Transcript of Assignment Number 1 -Answers
Assignment Number 1The problems use the Customer, OrderTbl, and Employee tables of the simplified Order Entry database. Chapters 4and 10 extend the database to increase its usefulness. The Customer table contains clients who have placed orders.The OrderTbl contains basic facts about customer orders. The Employee table contains facts about employees whotake orders. The primary keys of the tables are CustNo for Customer, EmpNo for Employee, and OrdNo for OrderTbl.
Customer
CustNoCustFirstName
CustLastName
CustCity
CustState CustZip
CustBal
C0954327 Sheri Gordon
Littleton CO
80129-5543 230
C1010398 Jim Glussman Denver CO
80111-0033 200
C2388597 Beth Taylor Seattle WA
98103-1121 500
C3340959 Betty Wise Seattle WA
98178-3311 200
C3499503 Bob Mann
Monroe WA
98013-1095 0
C8543321 Ron Thompson Renton WA
98666-1289 85
Employee
EmpNoEmpFirstName
EmpLastName EmpPhone EmpEmail
E1329594 Landi Santos
(303) 789-1234
E8544399 Joe Jenkins
(303) 221-9875
E8843211 Amy Tang
(303) 556-4321 [email protected]
E9345771 Colin White
(303) 221-4453
E9884325 Thomas Johnson
(303) 556-9987
E9954302 Mary Hill
(303) 556-9871 [email protected]
Orders
OrdNoOrdDate CustNo EmpNo
O1116324
1/23/13
C0954327
E8544399
O2334661
1/14/13
C0954327
E1329594
O3331222
1/13/13
C1010398
O22334 1/12/1 C23885 E98843
57 3 97 25O4714645
1/11/13
C2388597
E1329594
O5511365
1/22/13
C3340959
E9884325
O7989497
1/16/13
C3499503
E9345771
O1656777
2/11/13
C8543321
O7959898
2/19/13
C8543321
E8544399
Question 8: Show the result of a restrict operation that lists the orders in February 2013.Ans:
OrdNo OrdDate CustNo EmpNoO1656777
02/11/2013 C8543321
O7959898
02/19/2013 C8543321 E8544399
Question 9: Show the result of a restrict operation that lists the customers residing in Seattle, WA.Ans:
CustNo CustFirstName
CustLastName CustCity CustState
CustZip CustBal
C2388597 Beth Taylor Seattle WA 98103-1121 $500.00C3340959 Betty Wise Seattle WA 98178-3311 $200.00
Question 11: Show the result of a project operation that lists the CustCity and CustState columns of the Customer table.Ans:
CustCity CustStateLittleton CODenver COSeattle WASeattle WAMonroe WARenton WA
Question 14: Show the result of a natural join of the Employee and OrderTbl tables.Ans:
EmpNo
EmpFirstName
EmpLastName
EmpPhone
EmpEmail OrdNo OrdDate
CustNo EmpNo
E8544399
Joe Jenkins (303) 221-9875
O1116324
01/23/13
C0954327
E8544399
E1329594
Landi Santos (303) 789-
O2334661
01/14/13
C0954327
E1329594
1234E9884325
Thomas Johnson (303) 556-9987
O2233457
01/12/13
C2388597
E9884325
E1329594
Landi Santos (303) 789-1234
O4714645
01/11/13
C2388597
E1329594
E9884325
Thomas Johnson (303) 556-9987
O5511365
01/22/13
C3340959
E9884325
E9345771
Colin White (303) 221-4453
O7989497
01/16/13
C3499503
E9345771
E8544399
Joe Jenkins (303) 221-9875
O7959898
02/19/13
C8543321
E8544399
Question 15:Show the result of a one-sided outer join between the Employee and OrderTbl tables. Preserve the rows of the OrderTbl table in the resultAns:
OrdNo OrdDate
CustNo
EmpNo
EmpNo
EmpFirstName
EmpLastName
EmpPhone
EmpEmail
O1116324
01/23/13
C0954327
E8544399
E8544399
Joe Jenkins (303) 221-9875
O2334661
01/14/13
C0954327
E1329594
E1329594
Landi Santos (303) 789-1234
O3331222
01/13/13
C1010398
O2233457
01/12/13
C2388597
E9884325
E9884325
Thomas Johnson (303) 556-9987
O4714645
01/11/13
C2388597
E1329594
E1329594
Landi Santos (303) 789-1234
O5511365
01/22/13
C3340959
E9884325
E9884325
Thomas Johnson (303) 556-9987
O7989497
01/16/13
C3499503
E9345771
E9345771
Colin White (303) 221-4453
O1656777
02/11/13
C8543321
O7959898
02/19/13
C8543321
E8544399
E8544399
Joe Jenkins (303) 221-9875
Question 16: Show the result of a full outer join between the Employee and OrderTbl tables. Ans:
OrdNo OrdDate
CustNo
EmpNo
EmpNo
EmpFirstName
EmpLastName
EmpPhone
EmpEmail
O1116324
01/23/13
C0954327
E8544399
E8544399
Joe Jenkins (303) 221-9875
O2334661
01/14/13
C0954327
E1329594
E1329594
Landi Santos (303) 789-1234
O3331222
01/13/13
C1010398
O2233457
01/12/13
C2388597
E9884325
E9884325
Thomas Johnson (303) 556-9987
O4714645
01/11/13
C2388597
E1329594
E1329594
Landi Santos (303) 789-1234
O5511365
01/22/13
C3340959
E9884325
E9884325
Thomas Johnson (303) 556-9987
O7989497
01/16/13
C3499503
E9345771
E9345771
Colin White (303) 221-4453
O1656777
02/11/13
C8543321
O7959898
02/19/13
C8543321
E8544399
E8544399
Joe Jenkins (303) 221-9875
E8843211
Amy Tang (303) 556-4321
E9954302
Mary Hill (303) 556-9871
Q17: Show the result of the restrict operation on Customer where the condition is CustCity equals “Denver” or “Seattle”followed by a project operation to retain the CustNo, CustFirstName, CustLastName, and CustCity columns.Ans:
CustNoCustFirstName
CustLastName
CustCity
C1010398 Jim Glussman DenverC2388597 Beth Taylor Seattle
C3340959 Betty Wise Seattle
Q18:Show the result of a natural join that combines the Customer and OrderTbl tables followed by a restrict operationto retain only the Colorado customers (CustState = “CO”).Ans:
CustNo
CustFirstName
CustLastName
CustCity
CustState
CustZip
CustBal
OrdNo OrdDate
EmpNo
C0954327
Sheri Gordon Littleton
CO 80129-5543
230$ O1116324
01/23/13
E8544399
C0954327
Sheri Gordon Littleton
CO 80129-5543
230$ O2334661
01/14/13
E1329594
C1010398
Jim Glussman Denver
CO 80111-0033
200$ O3331222
01/13/13
Q19:Show the result of a summarize operation on Customer. The grouping column is CustState and the aggregatecalculation is COUNT. COUNT shows the number of rows with the same value for the grouping column.
Ans:
NUMBER
CustState
2 CO4 WA
Q20:Show the result of a summarize operation on Customer. The grouping column is CustState and the aggregatecalculations are the minimum and maximum CustBal valuesAns:
MIN BALANCE
MAX BALANCE
CustState
200$ 230$ CO0$ 500$ WA