Assignment Number 1 - Answers
Assignment Number 1 - Answers
The problems use the Customer, OrderTbl, and Employee tables of the simplified Order Entry database. Chapters 4
and 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 who
take orders. The primary keys of the tables are CustNo for Customer, EmpNo for Employee, and OrdNo for
OrderTbl.
Customer
CustNo
C095432
7
C101039
8
C238859
7
C334095
9
C349950
3
C854332
1
CustFirstNa
me
CustLastNa
me
CustStat
e
Gordon
CustCit
y
Littleto
n
Sheri
Jim
Glussman
Denver
CO
Beth
Taylor
Seattle
WA
Betty
Wise
WA
Bob
Mann
Seattle
Monro
e
Ron
Thompson
Renton
WA
EmpFirstNa
me
EmpLastNa
me
Landi
Santos
Joe
Jenkins
Amy
Tang
Colin
White
Thomas
Johnson
Mary
Hill
CO
WA
CustZip
801295543
801110033
981031121
981783311
980131095
986661289
CustBa
l
Employee
EmpNo
E13295
94
E85443
99
E88432
11
E93457
71
E98843
25
E99543
02
Orders
OrdNo
O11163
24
O23346
61
O33312
22
O22334
OrdDa
te
1/23/1
3
1/14/1
3
1/13/1
3
1/12/1
CustNo
C09543
27
C09543
27
C10103
98
C23885
EmpNo
E85443
99
E13295
94
E98843
EmpPhone
(303) 7891234
(303) 2219875
(303) 5564321
(303) 2214453
(303) 5569987
(303) 5569871
EmpEmail
[email protected]
m
[email protected]
m
[email protected]
[email protected]
m
[email protected]
om
[email protected]
230
200
500
200
0
85
57
O47146
45
O55113
65
O79894
97
O16567
77
O79598
98
3
1/11/1
3
1/22/1
3
1/16/1
3
2/11/1
3
2/19/1
3
97
C23885
97
C33409
59
C34995
03
C85433
21
C85433
21
25
E13295
94
E98843
25
E93457
71
E85443
99
Question 8: Show the result of a restrict operation that lists the orders in February 2013.
Ans:
OrdNo
O1656777
O7959898
OrdDate
02/11/2013
02/19/2013
CustNo
C8543321
C8543321
EmpNo
E8544399
Question 9: Show the result of a restrict operation that lists the customers residing in Seattle, WA.
Ans:
CustNo
C2388597
C3340959
CustFirstName
Beth
Betty
CustLastName
Taylor
Wise
CustCity
Seattle
Seattle
CustState
WA
WA
CustZip
98103-1121
98178-3311
CustBal
$500.00
$200.00
Question 11: Show the result of a project operation that lists the CustCity and CustState columns of the Customer
table.
Ans:
CustCity
Littleton
Denver
Seattle
Seattle
Monroe
Renton
CustState
CO
CO
WA
WA
WA
WA
Question 14: Show the result of a natural join of the Employee and OrderTbl tables.
Ans:
EmpN
o
E8544
399
EmpFirst
Name
Joe
EmpLast
Name
Jenkins
E1329
594
Landi
Santos
E9884
325
Thomas
Johnson
EmpP
hone
(303)
2219875
(303)
7891234
(303)
556-
EmpEmail
OrdNo
O1116
324
OrdD
ate
01/23
/13
CustN
o
C0954
327
EmpN
o
E8544
399
JJenkins@bigc
o.com
LSantos@bigc
o.com
O2334
661
01/14
/13
C0954
327
E1329
594
TJohnson@big
co.com
O2233
457
01/12
/13
C2388
597
E9884
325
E1329
594
Landi
Santos
E9884
325
Thomas
Johnson
E9345
771
Colin
White
E8544
399
Joe
Jenkins
9987
(303)
7891234
(303)
5569987
(303)
2214453
(303)
2219875
LSantos@bigc
o.com
O4714
645
01/11
/13
C2388
597
E1329
594
TJohnson@big
co.com
O5511
365
01/22
/13
C3340
959
E9884
325
CWhite@bigc
o.com
O7989
497
01/16
/13
C3499
503
E9345
771
JJenkins@bigc
o.com
O7959
898
02/19
/13
C8543
321
E8544
399
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 result
Ans:
OrdN
o
O1116
324
Ord
Date
01/23
/13
Cust
No
C0954
327
Emp
No
E8544
399
Emp
No
E8544
399
EmpFirst
Name
Joe
EmpLast
Name
Jenkins
O2334
661
01/14
/13
C0954
327
E1329
594
E1329
594
Landi
Santos
O3331
222
O2233
457
01/13
/13
01/12
/13
C1010
398
C2388
597
E9884
325
E9884
325
Thomas
Johnson
O4714
645
01/11
/13
C2388
597
E1329
594
E1329
594
Landi
Santos
O5511
365
01/22
/13
C3340
959
E9884
325
E9884
325
Thomas
Johnson
O7989
497
01/16
/13
C3499
503
E9345
771
E9345
771
Colin
White
O1656
777
O7959
898
02/11
/13
02/19
/13
C8543
321
C8543
321
E8544
399
E8544
399
Joe
Jenkins
EmpP
hone
(303)
2219875
(303)
7891234
EmpEmail
(303)
5569987
(303)
7891234
(303)
5569987
(303)
2214453
TJohnson@bi
gco.com
(303)
2219875
JJenkins@big
co.com
JJenkins@big
co.com
LSantos@bigc
o.com
LSantos@bigc
o.com
TJohnson@bi
gco.com
CWhite@bigc
o.com
Question 16: Show the result of a full outer join between the Employee and OrderTbl tables.
Ans:
OrdN
o
O1116
324
Ord
Date
01/23
/13
Cust
No
C0954
327
Emp
No
E8544
399
Emp
No
E8544
399
EmpFirst
Name
Joe
EmpLast
Name
Jenkins
O2334
661
01/14
/13
C0954
327
E1329
594
E1329
594
Landi
Santos
O3331
222
O2233
457
01/13
/13
01/12
/13
C1010
398
C2388
597
E9884
325
E9884
325
Thomas
Johnson
O4714
645
01/11
/13
C2388
597
E1329
594
E1329
594
Landi
Santos
O5511
365
01/22
/13
C3340
959
E9884
325
E9884
325
Thomas
Johnson
O7989
497
01/16
/13
C3499
503
E9345
771
E9345
771
Colin
White
O1656
777
O7959
898
02/11
/13
02/19
/13
C8543
321
C8543
321
E8544
399
E8544
399
Joe
Jenkins
E8843
211
Amy
Tang
E9954
302
Mary
Hill
EmpP
hone
(303)
2219875
(303)
7891234
EmpEmail
(303)
5569987
(303)
7891234
(303)
5569987
(303)
2214453
TJohnson@bi
gco.com
(303)
2219875
(303)
5564321
(303)
5569871
JJenkins@big
co.com
JJenkins@big
co.com
LSantos@bigc
o.com
LSantos@bigc
o.com
TJohnson@bi
gco.com
CWhite@bigc
o.com
ATang@bigco
.com
MHill@bigco.
com
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:
CustNo
C10103
98
C23885
97
C33409
59
CustFirstNa
me
CustLastNa
me
CustCi
ty
Jim
Glussman
Denver
Beth
Taylor
Seattle
Betty
Wise
Seattle
Q18:
Show the result of a natural join that combines the Customer and OrderTbl tables followed by a restrict operation
to retain only the Colorado customers (CustState = CO).
Ans:
CustN
o
C09543
27
C09543
27
C10103
98
CustFirstN
ame
Sheri
CustLastN
ame
Gordon
Sheri
Gordon
Jim
Glussman
CustC
ity
Littleto
n
Littleto
n
Denver
CustSt
ate
CO
CO
CO
CustZ
ip
80129
-5543
80129
-5543
80111
-0033
Cust
Bal
230$
230$
200$
OrdNo
O11163
24
O23346
61
O33312
22
OrdD
ate
01/23/
13
01/14/
13
01/13/
13
Q19:
Show the result of a summarize operation on Customer. The grouping column is CustState and the aggregate
calculation is COUNT. COUNT shows the number of rows with the same value for the grouping column.
Ans:
NUMB
ER
2
4
CustSta
te
CO
WA
Q20:
Show the result of a summarize operation on Customer. The grouping column is CustState and the aggregate
calculations are the minimum and maximum CustBal values
Ans:
MIN
BALAN
CE
200$
0$
MAX
BALAN
CE
230$
500$
CustSt
ate
CO
WA
EmpN
o
E85443
99
E13295
94