Question: The code provided is an example of a java-like pseudocode to show how you might write your answers, but is not supposed to be legal

The code provided is an example of a java-like pseudocode to show how you might write your answers, but is not supposed to be legal java or even logically correct. In particular, think what happens in Select if no tuples match the condition. You should assume the iterators do what makes sense (e.g., select.done() will be true if no tuples remain that match the condition, even if there are plenty of tuples left to be looked at.) There are a couple of ways to handle this (e.g., in Java you could use Exceptions, or you could Look ahead in select.done() to see if there were any matching tuples left. But I want you to practice thinking about the abstraction rather than the exact code; pseudocode often leaves details unspecified and you should know how to figure out those details for yourself.

Iterator class to scan a relation iterator relation_open(relation name) -- Construct an iterator to return tuples from table name tuple next() -- return a tuple from name that has not been returned since the -- relation was last opened. boolean done() -- True iff all tuples have been returned by calls to next() since -- the relation was opened, otherwise false Iterator class Select iterator select_open( iterator in, boolean condition(tuple t) ) -- Construct an iterator that cycles through in, returning tuples -- that satisfy condition tuple next() tuple t = in.next(); while not in.done() and not condition(t) t = in.next(); return t; boolean done() return in.done(); Iterator class project_multi_open iterator Project_multi( iterator in, list columns ) -- Construct an iterator that cycles through in, a tuple containing only the given columns -- This uses multiset semantics (duplicates are not eliminated) tuple next() tuple t = in.next(); tuple new_t = -- new tuple constructed from t using only attributes in list columns return new_t; boolean done() return in.done(); 
  1. Assume you have the above iterators (and that they work correctly). Write pseudocode to execute the relational algebra expression instructor,salary(name="Clifton"(instructor)), assuming by we mean a multiset projection (keep duplicates). Your code should be in the form of a demand-driven iterator as shown above (when your next() is called, it should then do the work to get the next tuple.) You'll need to make some assumptions about how you create lists and boolean functions to be passed as arguments. Remember, this is pseudocode, as long as it is clear and unambiguous, it doesn't need to execute in any known computer language.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!