Pages

Saturday 29 June 2013

What is Index in Database

Index:
Indexing is not one time exercise; it should be mold as per user interaction with application.
For example,
Consider we have an application with fields 
1) Student Id
2) Total Marks
3) Student name
4) Search button
If end user is inserting Student ID and hitting Search then it is fine if you add a CLUSERTED INDEX on
“Student Id” Column. Your application will work fine and will deliver fast results.

But one fine day, if end user starts Searching RESULTS entering STUDENT NAME and hitting SEARCH the actual problem starts.
The solution is, Add NON CLUSTERED INDEX to “STUDENT NAME” COLUMN that will solve your problem.
Conclusion: INDEXING is not one time activity.
Types of Indexes
There are two types of INDEXES.
1) Clustered Index.
2) Non Clustered Index.
Two understand above two types of indexes one should understand the architecture of INDEX.
INDEX internally utilizes B-tree Structure.
It has ROOT NODE, NON LEAF NODE AND LEAF NODE.
1) Clustered INDEX has DATA PAGE in LEAF NODE.[Means actual data resides here]
2) NON CLUSTERED INDEX has REFERENCE POINTER IN LEAF NODE.[A pointer address points to actual data from Leaf node]

0 comments:

Post a Comment