Master Mathematics.

Programming · Databases & SQL · Problem 4

Indexes that speed up a join

A disk-based database has Movie(ID, CustomerRating), Genre(ID, Name) and Movie_Genre(MovieID, GenreID). Consider

SELECT * FROM Movie, Genre, Movie_Genre
WHERE Movie.CustomerRating > 3.4 AND Genre.Name = "Comedy"
  AND Movie_Genre.MovieID = Movie.ID AND Movie_Genre.GenreID = Genre.ID;

This query can be sped up using which of the following indexing options?

  1. (A) B tree on all the attributes.
  2. (B) Hash index on Genre.Name and B tree on the remaining attributes.
  3. (C) Hash index on Movie.CustomerRating and B tree on the remaining attributes.
  4. (D) Hash index on all the attributes.

Source: GATE DA