Please use the on-line submit procedure, as described in Homework 3 to turn in your PDA. Give us hardcopy of your written part, as before.
SELECT Bars.address
FROM Drinkers, Bars
WHERE Drinkers.name = 'joe'
AND Drinkers.frequents = Bars.name;
we might use an index on Drinkers.name to help us find the
tuple for drinker Joe quickly.
We might also like an index on Bars.name, so we can take all
the bars Joe frequents and quickly find the tuples for those bars to
read their addresses.In Oracle, you can get an index by the command:
CREATE INDEX <IndexName> ON <RelName>(<Attribute List>)
TABLESPACE INDX;
Note:
If the attribute list contains more than one attribute, then the index requires values for all the listed attributes to find a tuple. That situation might be helpful if the attributes together form a key, for example. An illustration of the CREATE INDEX command is
CREATE INDEX DrinkerInd ON Drinkers(name)
TABLESPACE INDX;
CREATE INDEX BarInd ON Bars(name)
TABLESPACE INDX;
which creates the two indexes mentioned above.
To get rid of an index, you can say DROP INDEX followed by the
name of the index.
Notice that each index must have a name, even though we only refer to
the name if we want to drop the index.Create at least two useful indexes for your PDA. Run your queries from part (1) on your large database with the indexes and without the indexes. To time your commands, you may issue the following commands to sqlplus:
Naturally these times may be affected by external factors such as system load, etc. Still, you should see a dramatic difference between the execution times with indexes and the times without. Turn in a script showing your commands to create indexes, and showing the relative times of query execution with and without indexes.
Note: Often, students discover that indexes appear to slow down the execution of queries. There are two issues you should consider:
Ownership(owner, numberOfCars, numberOfMotorcycles)with all the owners in Cars and in Motorcycles and includes the counts of their cars and motorcycles. Make sure this request works for people who own both car(s) and motorcycle(s), car(s) but not motorcycle(s), and motorcycle(s) and not car(s).