Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

*AS ALWAYS ALL QUERIES MUST BE DATA INDEPENDENT*\' (PLEASE COMPLETE IN SQL ORACL

ID: 3818144 • Letter: #

Question

*AS ALWAYS ALL QUERIES MUST BE DATA INDEPENDENT*' (PLEASE COMPLETE IN SQL ORACLE)

1.      Ben and Jerry are stating a new flavor, a mix of Vanilla, Cookie and almond. List the names of customers that like either of these flavors.

2.      Give the names of flavors that cost more than $500 (total). Hint: may want to create view for this

NEEDED INFORMATION!!!!!

ICECREAM (Ice_cream_ID, Ice_cream_flavor, price, years_first_offered, sellling _status)

INGREDIENT( Ingredient_ID, Ingredient_name, cost)

RECIPE (Ice_cream_ID, ingredient_ID, quantity_used)

CUSTOMER (Cust_ID, Cust_name, year_born)

Customer_and_Flavor_id (cust_id, Flavor_id)

WHERE:

Ice_cream_ID is the internal Id given to an ice cream.

Ingredient_ID is the internal Id given to an ingredient

selling_staus is an internal control which keeps track of ice cream sales as high, low, medium or none. If no figures are available this field has no value.

Years_first_offered is the year that ice cream was first offered

quantity_used is the amount of ingredient used in a given ice cream


ICECREAM TABLE

INGREDIENT TABLE

RECIPE TABLE

CUSTOMER TABLE

CUSTOMER_AND_FLAVOR_ID TABLE

ICE CREAM ID ICE CREAM FLAVOR 101 berry 201 vanilla 211 cherry 311 chocolate 321 strawberry 405 pistachio 406 almond 307 blackberry 510 mint 520 Cookie 525 green tea ICE CREAM ID ICE CREAM FLAVOR 540 raspberry 545 banana 550 pineapple 560 coconut 15 rows selected. PRICE YEAR FIRST OFFERED SELLIN 2010 null 1981 high 2.5 1976 low 1981 high 1961 high 2.5 2012 low 2010 null 2015 null 1.5 1998 medium 2001 medium 4.5 2012 low PRICE YEAR FIRST OFFERED SELLIN 2012 null 1992 medium 1.5 2.5 2001 high 3.25 2012 medium

Explanation / Answer

1)
select C.name from CUSTOMER C,Customer_and_Flavor_id CF,ICECREAM I where C.Cust_ID=CF.Cust_ID and CF. Flavor_id=I.Ice_cream_ID and ( I.Ice_cream_flavor='almond' or .Ice_cream_flavor='cookie' or .Ice_cream_flavor='vanila' );

2)

select Ice_cream_flavor from ICECREAM IC,RECIPE R,INGREDIENT I where IC.Ice_cream_ID=R.Ice_cream_ID and I.Ingredient_ID=R.Ingredient_ID and (R.quantity_used *I.cost)>500;