21 21 votes An OTT company is maintaining a large disk-based relational database of different movies with the following schema:\[\begin{array}{l}\text { Movie (ID, CustomerRating) } \\\text { Genre (ID, Name) } \\\text { Movie_Genre (MovieID, GenreID) }\end{array}\]Consider the following SQL query on the relation database above: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 SQL query can be sped up using which of the following indexing options?$\mathrm{B}^{+}$tree on all the attributes.Hash index on Genre.Name and $\mathrm{B}^{+}$tree on the remaining attributes.Hash index on Movie.CustomerRating and $\mathrm{B}^{+}$tree on the remaining attributes.Hash index on all the attributes. Databases gate-ds-ai-2024 sql databases multiple-selects two-marks + – Arjun 6.7k views answer comment Share Follow Print See 1 comment 1 1 comment reply Amoljadhav commented Sep 14, 2024 reply Follow flag @deepakpunia sir plz explain the concept of hashed index onto the queries 4 4 replyShare Please log in or register to add a comment.
Best answer 24 24 votes $A)$ As We know $B^+$ trees are good in Range queries if we make $B^+$ tree on all attributes then it will defintely Speed up query.$B)$ Hash based indexing is good in equality Search. so if we make hash index on $Genre.name$ it will Give only $Comedy$ genre names and for remaining attributes we can make $ B^+$ trees .$C)$ if We make hash index on Customer rating then it will not efficiently give output and will not speed up the query .$D)$ same Reason as Previous . that's Why $A$ and $B$ are suitable answers here.here is refernce :Wisc university slides , stack overflowsimilar question : Databases: GATE CSE 2011 | Question: 39 (gateoverflow.in) screen shot of navathe : chap-$ 14$ , page $659$ ꧁༒☬ĿọŗԀ 🆂🅷🅸🆅🅰☬༒꧂ answered Jul 13, 2024 • edited Sep 19, 2024 by ꧁༒☬ĿọŗԀ 🆂🅷🅸🆅🅰☬༒꧂ ꧁༒☬ĿọŗԀ 🆂🅷🅸🆅🅰☬༒꧂ comment Share Follow See all 2 Comments 2 2 Comments reply sru12 commented Feb 17, 2025 reply Follow flag so if there are 100 comedy movies so how will it store it in hash table will it not create linear probing 0 0 replyShare Sri28 commented Jan 28 reply Follow flag It will store 100 comedy movies through chaining. @sru12 1 1 replyShare Please log in or register to add a comment.
17 17 votes B+ tree can be used on all attributes while hashed index can be used only on equality attributes. So option A and B correct. liontig37 answered Feb 17, 2024 liontig37 comment Share Follow See all 3 Comments 3 3 Comments reply Shaik Masthan commented Jul 16, 2024 reply Follow flag Straight to the point. 3 3 replyShare Sri28 commented Feb 13, 2025 reply Follow flag What you mean by equality attributes? @liontig37 0 0 replyShare Jayvijay Chauhan commented Sep 29 reply Follow flag @Sri28 1 1 replyShare Please log in or register to add a comment.
1 1 vote A. B+ tree on all the attributes.This is a robust solution. B+ trees handle the range query on CustomerRating well, and also efficiently handle the equality queries on Genre.Name and all join conditions.B. Hash index on Genre.Name and B+ tree on the remaining attributes.This specifically optimizes the Genre.Name = "Comedy" equality lookup with a Hash index (potentially faster than B+ tree for exact match).It ensures a B+ tree is used for Movie.CustomerRating (essential for the range query) and for all the ID columns involved in joins. This is a very strong candidate.C. Hash index on Movie.CustomerRating and B+ tree on the remaining attributes.This is incorrect. Placing a Hash index on Movie.CustomerRating would severely hamper the performance of the range query (> 3.4), as hash indexes are not suitable for ranges.D. Hash index on all the attributes.This is incorrect. Similar to option C, using a Hash index on Movie.CustomerRating would make the range query inefficient.so A, B are correct Prime2304 answered Jul 19, 2025 Prime2304 comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes HASH INDEX IS BEST FOR THE PERTICULAR VALUE SEARCH BUT RANGE QUERY ARE BEST IN B + TREE BUT ALSO WE CAN SEARCH THE PARTICULAR VALUE IN B+ TREE IN OPTION A THEY SEARCH ALL THE ATTRIBUTE IN B + TREE THATS COMPLETELY FINE IN OPTION B THEY SEAR THE PARTUCULAT COMEDY MOVIE USING HASH AND OTHER ARE B+ TREE BUT IN OPTION C THEY PERFORM THE RAGE QUERIES IN HASH INDEX WHICH IS INRORRECT SIMILARLY OPTION D ALSO INCORRECT SWAYANSHUSHEKHER answered Jun 30, 2025 SWAYANSHUSHEKHER comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes Option B : Correct Remember this Simple Concept. soudipta_dutta answered Jan 28 soudipta_dutta comment Share Follow 0 reply Please log in or register to add a comment.