开发者

How to choose an index

Can anyone explain and answer the following questions to me? I am having troubl开发者_运维技巧e understanding them. Really appreciate for your help

Choose an index for each of the following SELECT statements. Specify whether your choice is clustered or unclustered and whether it is a hash index or a B+ tree.

a. SELECT S.Name
FROM Student S
WHERE S.Id = ’111111111’

b. SELECT S.Name
FROM Student S
WHERE S.Status = ’Freshman’

c. SELECT T.StudId
FROM Transcript T
WHERE T.Grade = ’B’ AND T.CrsCode = ’CS305’

d. SELECT P.Name
FROM Professor P
WHERE P.Salary BETWEEN 20000 AND 150000

e. SELECT T.ProfId
FROM Teaching T
WHERE T.CrsCode LIKE ’CS%’ AND T.Semester = ’F2000’

I really qppreciate for all of your comments, I don't have any experience related to this topic, I am just reading a book and am would like to know how to do the following questions. It is for self-learning not for a school homework.


You need to apply your knowledge of what indexes are and how they work to each scenario - in most real-world situations its not possible to know exactly what indexes are needed without testing using representative data, but you can usually come up with a good guess as to what the optimal indexes will be - especially with the relatively simple examples you have posted.

Read up some more on indexes and then for each question think carefully about what columns are involved and how the results will be filtered.

There are plenty of resources on indexes available via Google, An Introduction to Clustered and Non-Clustered Index Data Structures looks like a good starting point.

If you need any further help then you will be best served by posting specific questions about specific examples.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜