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...
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.
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?
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...
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...
Please Select a Product and Make it on that product Project Description: Student groups will select...
Please Select a Product and Make it on that product Project Description: Student groups will select an industrial project to be developed throughout the semester. Students groups will select an appropriate project and define measurable project objectives and requirements. A project plan and schedule will be generated as well as resources allocated to accomplish project objectives. Prepare a group project for the class. Use as your model one of the following 1. Construction project 2. Software development project 3. Events...
Select a specific real-world firm or market that we have not discussed in class or the...
Select a specific real-world firm or market that we have not discussed in class or the textbook and discuss which model of market structure you think would be most appropriate to describe that market. (ie. Perfect competition, monopolistic competition, oligopoly, monopoly.) Real world markets never exactly meet the assumptions of the models, so you can also talk about what aspects of the real-world market may not fit the model what aspects are not well described by the model selected. You...
Select one disability that was discussed in class. Focusing on this one disability, please comment on...
Select one disability that was discussed in class. Focusing on this one disability, please comment on the disadvantages faced by persons with this disability, and the extent to which you believe that the current public policies that are in force are enough to overcome these disadvantages. What types of additional public policies or laws might be more effective in overcoming these disadvantages? answer is a short answer way. 5 sentences please.
Use the following class for the following problem. The only purpose of the class is to...
Use the following class for the following problem. The only purpose of the class is to display a message both when the constructor is invoked and when the destructor is executed. class Trace { public: Trace(string n); ~Trace(); private: string name; }; Trace::Trace(string n) : name(n) { cout << "Entering " << name << "\n"; } Trace::~Trace() { cout << "Exiting " << name << "\n"; } Requirement: Extend the class Trace with a copy constructor and an assignment operator,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT