20.02.2013 Views

Lecture 8 Objectives Physical Database Design

Lecture 8 Objectives Physical Database Design

Lecture 8 Objectives Physical Database Design

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

E246WFC<br />

G123RMR<br />

G889VDU<br />

H203PBR<br />

H311MHG<br />

…<br />

Primary Index Example cont.<br />

3000 records, 13 bytes each<br />

39 blocks, 78 records each<br />

Primary Index File<br />

…<br />

7 bytes 6 bytes<br />

to read block<br />

Block access = ⎡log2 39⎤+ 1 = 6<br />

(compare with 12 for a binary search)<br />

30,000 records, 100 bytes each<br />

3000 blocks, 10 records<br />

Main Data File<br />

E246WFC 7648378<br />

F651DEK 3096275<br />

G123RMR 7493874<br />

G551JBA 2098377<br />

G889VDU 6587969<br />

G994PBR 5675789<br />

H203PBR 4654786<br />

H266MHU 6345234<br />

H311MHG 5675489<br />

H626RPG 5673455<br />

Clustering Index Example<br />

Consider the same relation: Cars(reg#, engine#, make, model, price)<br />

Assume clustering field is: make<br />

Clustering<br />

Clustering Index File<br />

Clustering Block<br />

Main Data File Filed<br />

G551JBA 7648378 Fiat<br />

F651DEK 3096275 Ford<br />

1<br />

Filed Value Pointer<br />

Fiat<br />

Ford<br />

Renault<br />

Rover<br />

Vauxhall<br />

G123RMR 7493874 Ford<br />

E246WFC 2098377 Ford<br />

G889VDU 6587969 Renault<br />

H266MHU 5675789 Renault<br />

H203PBR 4654786 Renault<br />

G994PBR 6345234 Rover<br />

H311MHG 5675489 Rover<br />

H626RPG 5673455 Vauxhall<br />

1<br />

2<br />

3<br />

4<br />

5<br />

2<br />

3<br />

4<br />

5<br />

1024<br />

block<br />

size<br />

37<br />

39<br />

Clustering Index<br />

• If records of a file are physically ordered on a non-key<br />

field. That field is called the clustering field.<br />

• A clustering index differs from a primary index, which<br />

requires that the ordering field of the data file have a<br />

distinct value for each record.<br />

• There is one entry in the clustering index for each<br />

distinct value of the clustering field. This is an example<br />

of a dense index.<br />

• A data file can have at most one primary index or one<br />

clustering index.<br />

Secondary Index<br />

• A secondary index is also an ordered file with<br />

two fields. The first field is of the same type as<br />

some non-ordering field of the data file. The<br />

second field is a block pointer or a record<br />

pointer.<br />

• There can be many secondary indexes for the<br />

same data file.<br />

38<br />

40

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!