GATE CS - DATABASES (DBMS):Indexing and File Organization

Mastering indexing and file organization concepts and implementation.

Indexing for GATE CS

GATE indexing asks dense vs sparse, primary vs secondary, and B/B+ tree fan-out or height estimates. File-organization buzzwords are secondary.

Why an index

An index is a separate structure that maps search-key → record pointer(s) so you avoid scanning the whole file.

TypeIdea
DenseIndex entry for every search-key value
SparseIndex entry per block (sorted file)
PrimaryOn the ordering key of the file
SecondaryOn a non-ordering attribute (may be non-unique)
ClusteredFile order matches index order (≈ primary on ordered file)

B+ trees (the usual GATE tree)

  • Data in leaves only; internal nodes = routers
  • Leaves linked for range scans
  • All leaves at same depth

Height / fan-out questions: given order or max children, bound the number of levels for nn keys. Roughly: more fan-out ⇒ shorter tree.

B tree vs B+: B trees can store records in internal nodes; B+ keep them in leaves — GATE may ask which supports faster range queries (B+).

Hash indexes

Static hashing: h(k)h(k) → bucket. Dynamic (extendible / linear) appear less often. Good for equality; weak for ranges compared with B+.

Cost intuition

Unindexed select: O(blocks)O(\text{blocks}). Indexed equality: height + data block(s). Know that a bad secondary index on a low-selectivity column can be worse than a scan.

Previous: Transactions. Practice: GATE hub.