Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. We want to support set semantics, and have created a Project_dedup iterator that works just like Project_multi, except that it eliminates duplicates. How would your code to execute the query instructor,salary(name="Clifton"(instructor)) change if you wanted it use set semantics (the removes duplicates.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions

Question

How to find if any no. is divisble by 4 or not ?

Answered: 1 week ago

Question

Explain the Pascals Law ?

Answered: 1 week ago

Question

=+4 Develop and deliver the CCT program.

Answered: 1 week ago