Table

advertisement
WI09 CSE200 QUIZ#4
Name _________________________________ Seat# ________ Lab=> Friday ______ 1:30pm______ 3:30pm
Instructions:
 Put away all books, papers, and calculators. Turn off all beepers and cell phones.
 Answers must be legible or they will be marked incorrect.
 Be sure that all answers are SYNTACTICALLY correct i.e. as you would see them prior to running the query.
Remember to put quotes on the like and text values and pound signs around dates.
 Aggregate functions: Group By, Sum, Avg, Min, Max, Count, Where, Expression.
 REMEMBER that all the data is not shown. Be sure your queries will work with additional records.
 Prior to starting to write the queries, assume you have corrected all the data integrity issues, if any.
The tables given represent the database system for the Excel-lence Ice Cream Company. The following tables are being
used to collect information about the orders taken:
The FLAVOR table is a list of ice cream, frozen yogurt and sorbet flavors offered to customers with the calories per one
single scoop also given.
The CONE table defines the type and size of the cone options as well as the calories per cone type. There are 3 different
types of cones – sugar, bowl and waffle – and there are three sizes for each cone type – small, medium and large. The
unique cone identification value, that is, the field name “cid”, is created from the first letter of the cone type followed by
the first letter of the cone size. This field will always be length 2.
The ORDERS table is a list of orders taken from customers. The number of scoops designated will always be assumed to
be scoops of the same flavor as designated by the flavor id field.
REMEMBER THAT ALL OF QUERIES ARE SINGLE TABLE QUERIES ONLY
Using more than one table will be counted as INCORRECT
ORDERS
CONE
cid
SS
WS
BS
SM
WM
BM
SL
WL
BL
type
sugar
waffle
bowl
sugar
waffle
bowl
sugar
waffle
bowl
size
small
small
small
medium
medium
medium
large
large
large
calories
50
100
150
80
150
200
100
260
300
num
order# flavorid coneid scoops price
1
1
SS
2
$2.50
2
8
BS
1
$2.25
3
6
WS
1
$2.00
4
4
SM
2
$2.75
FLAVOR
5
7
BL
3
$4.75
6
2
BM
2
$3.50
flavor# flavor
7
8
WL
2
$3.50
1
black cherry swirl
8
3
BL
3
$4.75
2
choc chip cookie dough
9
1
WS
1
$2.00
3
choc fudge brownie
10
4
SL
2
$3.00
4
cookies and cream
11
3
BM
3
$4.25
5
mango peach
12
2
WM
2
$3.00
6
raspberry chip
13
4
SS
1
$1.75
7
strawberry
14
2
BS
1
$2.25
8
vanilla bean
CSE 200 KReeves Quiz4 WI09
type
frozen yogurt
ice cream
ice cream
ice cream
sorbet
ice cream
sorbet
frozen yogurt
Page 1
cals per
scoop
180
170
200
150
50
120
60
100
1.
(8 pts) Database Relationships. Set up the relationships of this database. Using the boxes below, fill in the primary
key (if any) and foreign key (s) (if any) of each table and draw relationship lines between tables.
CONE table
Primary Key
FLAVOR table
Primary Key
ORDERS table
Primary Key
Foreign Key(s)
Foreign Key(s)
Foreign Key(s)
2. (4 pts) When creating my relationships, I accidently related the order# field on the orders table and the flavor# field
on the flavor table. Name two reasons why this was the wrong thing to do.
3. (10 pts) You are trying to make healthy dessert choices. Using the query design view below, construct a query to
determine a list of all the frozen yogurt flavor options as well as any other flavor that has less than 100 calories per
scoop. Sort the list alphabetically by type then smallest to largest by calories per scoop. Below, fill out the dynaset
that this query will give as a result.
TABLE(S):
JOIN TYPE:
Field
Table
Total
Sort
Show
Criteria
OR
OR
RELATIVE TO:
Additional room for Expressions, if necessary
Query3
CSE 200 KReeves Quiz4 WI09
Page 2
Name _________________________________ Seat# ________ Lab=> Friday ______ 1:30pm______ 3:30pm
ORDERS
CONE
cid
SS
WS
BS
SM
WM
BM
SL
WL
BL
type
sugar
waffle
bowl
sugar
waffle
bowl
sugar
waffle
bowl
size
small
small
small
medium
medium
medium
large
large
large
calories
50
100
150
80
150
200
100
260
300
num
order# flavorid coneid scoops price
1
1
SS
2
$2.50
2
8
BS
1
$2.25
3
6
WS
1
$2.00
4
4
SM
2
$2.75
5
7
BL
3
$4.75
6
2
BM
2
$3.50
7
8
WL
2
$3.50
8
3
BL
3
$4.75
9
1
WS
1
$2.00
10
4
SL
2
$3.00
11
3
BM
3
$4.25
12
2
WM
2
$3.00
13
4
SS
1
$1.75
14
2
BS
1
$2.25
FLAVOR
flavor#
1
2
3
4
5
6
7
8
flavor
black cherry swirl
choc chip cookie dough
choc fudge brownie
cookies and cream
mango peach
raspberry chip
strawberry
vanilla bean
type
frozen yogurt
ice cream
ice cream
ice cream
sorbet
ice cream
sorbet
frozen yogurt
cals per
scoop
180
170
200
150
50
120
60
100
4. (7 pts) Another possible healthy dessert choice option is defined as follows. Using the query design view below,
construct a query to determine a list of all the flavors that have frozen yogurt type with less than 120 calories per
scoop and all the ice cream types with less than 150 calories per scoop.
TABLE(S):
JOIN TYPE:
Field
Table
Total
Sort
Show
Criteria
OR
OR
RELATIVE TO:
Additional room for Expressions, if necessary
5. (7 pts) Using the query design view below and only the ORDERS table, construct a query to determine a list of all the
small cones with 2 scoops. List the flavor identification value and the cone type value as well as the number of scoops
for that order.
TABLE(S):
JOIN TYPE:
RELATIVE TO:
Field
Table
Total
Sort
Show
Criteria
OR
OR
Additional room for Expressions, if necessary
CSE 200 KReeves Quiz4 WI09
Page 3
6. (7 pts) The following is the resulting dynaset of a query designed to summarize by flavor, the total number of scoops
per flavor as well as the total number of orders that were filled. In the query design view given below, create the query
that will create the given resulting dynaset.
Query6
flavorid SumOfnumscoops CountOforder#
1
3
2
2
5
3
3
6
2
4
5
3
6
1
1
7
3
1
8
3
2
TABLE(S):
JOIN TYPE:
Field
Table
Total
Sort
Show
Criteria
OR
OR
RELATIVE TO:
Additional room for Expressions, if necessary
7. (7 pts) Using the query design view below, construct a query to determine the cost of each scoop per order based on
the fact that the cost of each cone is 50% of the price given per order. Be sure to list for each order, the flavor
identification number, the number of scoops, the total price as given, and the price per scoop for that order.
TABLE(S):
JOIN TYPE:
Field
Table
Total
Sort
Show
Criteria
OR
OR
RELATIVE TO:
Additional room for Expressions, if necessary
SCORE ________/50
CSE 200 KReeves Quiz4 WI09
Page 4
Download