Question

In: Computer Science

Use only the operators discussed in class (select, project, Cartesian product, join, union, intersection, set difference...

Use only the operators discussed in class (select, project, Cartesian product, join, union, intersection, set difference and renaming). Type your answers.

Consider the following database schema:

INGREDIENT(ingredient-id,name,price-ounce)

RECIPE(recipe-id,name,country,time)

USES(rid,iid,quantity)

where INGREDIENT lists ingredient information (id, name, and the price per ounce); RECIPE lists recipe information (id, name, country of origin, and time it takes to cook it); and USES tells us which ingredients (and how much of each) a recipe uses. The primary key of each table is underlined; rid is a foreign key to RECIPE and iid is a foreign key to INGREDIENT.

Write the following queries in Relational Algebra.

(a) Find the names of French recipes that use butter and take longer than 45 minutes to cook.

(b) Find the names of recipes that use butter or lard.

(c) Find the names of recipes that use butter and lard.

(d) Find the name of recipes that do not use butter.

(e) Find the names of recipes that use 2 or more ingredients.

(f) (*) Find the names of recipes where at least 3 oz. (quantity) of every ingredient are used.

Solutions

Expert Solution

(a)

RECIPE.name( INGREDIENT.name = 'butter' and time > 45 and Country = 'France' RECIPE INGREDIENT )

(b)

RECIPE.name( INGREDIENT.name = 'butter' or INGREDIENT.name = 'lard' RECIPE INGREDIENT )

(c)

RECIPE.name( INGREDIENT.name = 'butter' and INGREDIENT.name = 'lard' RECIPE INGREDIENT )

(d)

RECIPE.name( INGREDIENT.name != 'butter' RECIPE INGREDIENT )

(e)

RECIPE.name( G count( INGREDIENT.name) >=2 RECIPE INGREDIENT )

(f)

RECIPE.name( quantity >=3 RECIPE USES INGREDIENT ) name( INGREDIENT )

Do ask if any doubt. Please upvote.


Related Solutions

Use only the operators discussed in class (select, project, Cartesian product, join, union, intersection, set difference...
Use only the operators discussed in class (select, project, Cartesian product, join, union, intersection, set difference and renaming). Type your answers. The following database schema is given: ATHLETE(name,age,height,weight,country) RACE(id,location,date,time-start,distance) COMPETES(aname,rid,time,position) where ATHLETE has information about runners (their name, age, height, weight, and nationality); RACE has information about races (id, location, date when it’s held, time it starts, and distance ran); and COMPETES keeps track of which runners run on with race, the time it took them to complete the race,...
Write the following questions as queries in SQL. Use only the operators discussed in class (no...
Write the following questions as queries in SQL. Use only the operators discussed in class (no outer joins) Consider the following database schema: INGREDIENT(ingredient-id,name,price-ounce) RECIPE(recipe-id,name,country,time) USES(rid,iid,quantity) where INGREDIENT lists ingredient information (id, name, and the price per ounce); RECIPE lists recipe information (id, name, country of origin, and time it takes to cook it); and USES tells us which ingredients (and how much of each) a recipe uses. The primary key of each table is underlined; rid is a foreign...
Write the following questions as queries in SQL. Use only the operators discussed in class (no...
Write the following questions as queries in SQL. Use only the operators discussed in class (no outer joins) Consider the following database schema: INGREDIENT(ingredient-id,name,price-ounce) RECIPE(recipe-id,name,country,time) USES(rid,iid,quantity) where INGREDIENT lists ingredient information (id, name, and the price per ounce); RECIPE lists recipe information (id, name, country of origin, and time it takes to cook it); and USES tells us which ingredients (and how much of each) a recipe uses. The primary key of each table is underlined; rid is a foreign...
Write the following questions as queries in RELATIONAL ALGEBRA. Use only the operators discussed in class...
Write the following questions as queries in RELATIONAL ALGEBRA. Use only the operators discussed in class (select, project, Cartesian product, join, union, intersection, set difference and renaming). The following database schema is given: ATHLETE(name,age,height,weight,country) RACE(id,location,date,time-start,distance) COMPETES(aname,rid,time,position) where ATHLETE has information about runners (their name, age, height, weight, and nationality); RACE has information about races (id, location, date when it’s held, time it starts, and distance ran); and COMPETES keeps track of which runners run on with race, the time it...
1. Implement the union set function using the prototype. 2. Implement the intersection set function using...
1. Implement the union set function using the prototype. 2. Implement the intersection set function using the prototype. 3. Implement the set difference function using the prototype. 4. Implement the subset function using the prototype.
Show that a set is convex if and only if its intersection with any line is...
Show that a set is convex if and only if its intersection with any line is convex. Show that a set is affine if and only if its intersection with any line is affine.
Given the set A = {‘ab’,22)} we know the Cartesian product A x A consists of...
Given the set A = {‘ab’,22)} we know the Cartesian product A x A consists of 4 tuples (=2 x 2) and any subset of the Cartesian product is a relation. There are 16 possible subsets ( = 24 ) HINT: The documents: Sets in python and mathematics and RelationPascalTriangleExamples Display the Cartesian product (4 tuples)                                                                                 ANS   {                         } Display one relation with 3 tuples   ANS {                          } Using the formula nCr, how many relations are there with 2...
Which were the first fifteen countries to join the European Union? Which do not use the...
Which were the first fifteen countries to join the European Union? Which do not use the Euro as their official currency? Did any of the fifteen members drop out of the European Union. If yes, which country?
This question is about the class Set, as discussed in the lectures. It represents a finite...
This question is about the class Set, as discussed in the lectures. It represents a finite set of int’s. Relevant parts of Set are shown below. The integer count holds the number of elements in the Set. The array elements holds the elements themselves. The class Set also has public methods addElement, equals, isIn, and toString. They are defined as in the lectures, and you can use them if you need to. class Set   {     private int count;     private int...
Overloading the insertion (<<) and extraction (>>) operators for class use requires creating operator functions that...
Overloading the insertion (<<) and extraction (>>) operators for class use requires creating operator functions that use these symbols but have a parameter list that includes a class ____. object address reference data type Flag this Question Question 210 pts When overloading the insertion operator to process a Complex object, it’s important to understand that you’re overloading an operator in the ____ class. istream operator Complex ostream Flag this Question Question 310 pts ____ class variables are allocated memory locations...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT