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.
In this assignment, we will continue to work with the book database from the previous assignment. However, we now make the book title and the year jointly be the key for books; this change is reflected in all relations. Here are the relations again:
In this database, each book may have one or more authors and each author may make a different amount of money from that book. One book may make reference to other books. One book may be reviewed by different reviewers and get different scores. An author could also be a reviewer and a publisher.
Do they have the same effect on foo? Suggest one effect at least
one of these statements could have on views
defined on foo?
Give an example of an effect they could have on indexes defined for
foo.
Give one way they could affect other relations in the database?
Consider the price attribute in BookPublish. Give one
example of a query where it makes more sense for
price to be null for unknown values, rather than a default value such as
0.
Explain your reasoning.
Notwithstanding that nobody knows why people care about computing Erdos Numbers, our database is expected to get a lot of queries on it. So, define views to find authors who have:
Note: You must consider books to be papers in the Erdos Number
definition.
CREATE TABLE Managers ( employee-name CHAR(20) NOT NULL, manager-name CHAR(20) NOT NULL, PRIMARY KEY (employee-name), FOREIGN KEY (manager-name) REFERENCES Managers(employee-name) ON DELETE CASCADE; )
Here, employee-name is the key for the table Managers, meaning that each employee has at most one manager. The foreign-key clause requires that every manager also be an employee. How would you start inserting tuples into this table? What happens when a tuple in the relation Managers is deleted? Would a ``set-null'' policy work here? Explain your reasoning briefly.