You are on page 1of 9

160/DBMS fta

f s sa fais F k r zta ii T faid ecoiary key index: duo icates may exist. It may be
Normalization| 161
Introduction
form of records. Every
is stored in dhe generated from a field whih is a candidate key and has
that data
data 5s used to recognize the
This keya field is Et ft 77
We know that
we know a
unique value in every recorc, or a non-key with du-
record ha a key ield.
is used to
technique which
is of plicate values.
Indexing tiles on the basis
record uniGueb: from the
database

retrieve records
some key field.
forbes ave
all the index main str
difficult to search hashing is
But, sometimes becomes
it
At that dime,
reach the desired da:a.
values and
to directly search the
location of de.
Used. It is a technique
the disk without using
index structure. This Address-inder
sired data 07
123ismith imain str
chapter deak
with these two techniques. 234joneS forbes ave
345 tomsonmain str
Indexing su r fN ZT f 456 stevens forbes ave
a is to get
data
database to storejnsert/update 567smith forbes ave
Main aim behind designing one can easily
and
quick access of any datadatabase.
secondary key index: typically, with 'postings lists'
delete datz of the for even one
size hence searching
As database is of large even a smallest transaction
record will teke time. Moreover reduce the
to
will take time to perform action. In order
the Postings s
in transactions, Indexes
are used. Concept be
time spent is similar to the one we
used in
forbes ave
hind indeaes used in DBMS
books. Indexing a data structure
is technique to efficiently main str 123 smith
database files based on he at- nan
retrieve records from the 234 joness :forbes a
has been done.
on vhich the indexing 345 tomson main str
tributes access to de-
Indexing mechanisms
are
used to speed up 458:stevens forbes ave
sired data. Eg. author catalog in library 567 smith
forbes ave
index entries) of the
index fle consists of records (called
An
form Clustering (= sparse) index: Clustering index is de
fined on an ordered data file. Records are
search-key pointer physicaly
sorted on that key (and rot all key values are neeced in
the index)
Search Key attribute to set of attributes used to look up
records in a fie.
Non-dustering (=dense) index: the opposite 7-zffT (TH) TA - aifaz (favta)
sf7 t Clustering'sparse indexon ssn
Index files are ypically much smaller than the original file ITT-TA: STfarT mg F Eg:
Ordered indexing is of two.types
Two basic kinds of indices: Sparse Index: contains index records for only some
Ordered indices: seanch keys are stored in sorted order search-key values. In sparse index, index records are not
for key.
Hash indices: search keys are distributed uniformly Created every search An index recordhere con-
tainsa search key and an actual poirter to the data on
acros "buckets using a "hash function'. he disk. To search a record, we first
Indexing are of following ypes: proceed
by
reccrd and reach at the actual location of the data. index
if we
Primarykey duplicates). Itis
index: onanprimary key (no file. are
unable to find the record then the system e1orms
generaly defined on Data is or
ordered data sequential search to find the desired data.
derec on a primary key (key field).

123 $nName Acdress


234 123 234 bnes forbesae
345 234 123 STrith man sr_
456 456
667
456 Seens | forbesae
123smlth maln st 345 oTEon| mEn Sr
234jones rbes ave Dense Index Files: Incex record appears for every
878 tomson main str search-key value in the fle. in dense index, there is an
456 stevens forbes ave index record for every s2arch key value in the database.
345 smith forbes ave his makes searching faser but requires more space to
store indexX records itsef. Index reccrds contain search
key vaiue and a pointer to the actual record on the disk.
ieinsnesiewikiteisiiiesis

Nomalization | 163
D E M S

161 123 SnName Address


234 234 bnes farbesae overflovs
455
123 Srith manstr
456 9ees |fabes ae 123 sm- 12 pte fthac
345 234 onesHorbes i & ptera fhac
345|_mn man strJ
ilevel I n d e x

,have already stuay


tnat
index records comprise of
hkey values and
k along with
data. Multilevel index is stored
on
the actual database files. As the size of Problen
size ot indices also increases.
alabase increases, the Hari i thusS:
in order to speed up the search operations it is neces- i i EI G 3TYR fa zqrA fTr overfl chains may become very long -

sl.ut lown & reorganize


to keep the index records in the main memory. if in
stuation Single-level index is used then one cannot st with ~80% utilization
index in memory. Hence it results in mul-
large size if index is twi large, store it on disk and keep index on the
disk access.
index (in enory)
jilevel index helps in breaking down the index into Hdee R EÄ faA BÈ I fAHTA TuSually t o vels of indices, one first- level entry per disk
indices in order to make T t fTa FT T T T B T1 5 block.
Halsmaller the outermost level KT7I F7
nall that it
can be saved in a single disk block, which at ferrer foer stt aad ä i st rafaa ct aInandorder nplement dynamic multlevel indexing, B-tree
o
be accomodated anywhere in the main memory. B uer re generally employed.

B-trees B-a
Imar Index Daablods 8 tree is.n xample of multilevel indexing. Record pointers
will be presnt at leaf nodes as well as on Internal nodes.
Quter inde
Daa Bocks
A
B/B+ Iree is a ropted tree satisfying thefollowing prop-
erties:
All path- from root to leaf are of the same length
Each iude that is not a root or a leaf has between
Datablodss n 2 : and n children.

A le.f 10de hasbetween (-1)/2) and n -1 values.


Special cases: If the root is not a leaf, it has at least 2
Daa Bods chitirc
fthether e
rot is a leaf (that is, there are no other nodes in
, it can have between 0 and (n-1) values.
8taa Update: Deletion
the in the file with its par- Ok g ) for everything! (ins/del/search)
ard -eted record was only record O(TT (N)) Fa T (ins/del T)
is deleted from the
4
ST aso.
value, Uhe
earch-key search-key
al'y, if >=
bypisutili.caton m =
s0 100, then 2 -3 levels
-

50%, guaranteed; on average 699%


favhva, z m-s0-100, a 2-3 Rar

Eg, B-tee of order 3: , T 3 1B-J:


123
123 123
3,423 455 123 smith main str |
234]jones forbes ave
345|tomson main str
458 stevens
|forbes ave
567 smith forbes ave
124; peterson; fth ave he
it
d wack ofB-tree used for indexing, however is that etn e-2 3r E E e
store ihe data pointer (a pointer to the disk file block
containin; the key value), corresponding to a partia1lar key
values, al ng with that key value in the node of a B-uee.
t4 DMS
Ths
tchnique,into
geatty redes the
number
mnode of a B-ree whichofresults
etriesinthat 2sin-1,4 Ta-j r z
the
ca be packed a B- ats dHds dA
Ig eH et
Tt ta
yA r aEu
agn *n &For 2isn
& which
-

1, al the search-keys in
sub-ree to
in Pi points have values greater than or cquai to ki K-1 1 2 E a rez
crease in the numder of leves in the B-tree. This all results f vfvTaT B-tree md Kiem id q Kah d a ns
in
oing he euch dime of a record. and less than Kq-1
Bt-tree for account file (n 3)
S e e eiminates the above
drawback
oinbers only at te leuf nodes oí the tree. by storing data B+ n at s atga T STa Nzel »il r K*
B tree is a
ary search uree that foilows bal-F seancn-

m The leaf nodes of a 8 tree muib-evel mdex tor-.


denote actual data - gRTt MHRT Ktm
point B* 119 44
e D u c k e

es ee ensures that al leai nodes


remain at the same search-k

beigh hus bakanced. Apart from this, the leaf nodes are s t kTY FHA ZT vt Td forrd uE an fle
irkd sing a link ist herefore a 8" and 4 values
tree can suppot ran R Leal nodes must have between 2
diam acres wel as sequertdal acces T frR 3vam FTT T . 5).
there
with n
T (-1)/2) and n -1, e r pa

Adantage of B+-tee index fles: automaticaily reorga- Non-leaf nodes other than root must have between 3 ety
es sef wh Smal, bcail, changes, in the R ITT- ard 37y attit wta
and deletiors face of inserdons tt frteeqa d ** ita,
atra, Ta, T Tq faFprrg1 and 5 children (fn/2) and n with n =5).
Reorganizaion cí endre file is not requirèed
maintain performance I TTTR *I A fN F ETRstufrar i T. Root must have at least 2 children.
. T**2

Disadvantage of B+-brees: etra insertion and deletion


Observations about B+-trees
Overhead, sace overhead
Since the inter-node connections are done by pointers, ngna
Adantages of B+tes outeigh diadvantages, and they logically" close blocks need not be "physically"
close.
are used etershelk
.The non-leaf levels of the B+-ree form a hierarchy of zud tëa - wno
B+-Tree Node Structure sparse indices. dkp)in
B TF =
small number of levels full, split
The B+-tree incontains a relatively
of the main file), thus searches
(logarithmic the size splitting o
can be conducted efficiently. s toun

Kare the searchkay value Queries on B+-Trees ncreasing


P are pointers to chdren for noneaf nodes) or pointers Find all records with a search-key value of k. TENTIO
to records or buckes of records fior leaf nods Start with the root node at the L
The search-eys in a node are ordered 1. Examine the node for the smallest search-key value upstairs;

>k.
K<K<Kg...<K 2. If such a value exists, assume it is K. Then follow P
2 f 3T t at a he
Leaf Nodes in B-Trees TT R TITR P upstairs

to the child node


For i 1, 2,.. n-1, pointer P, either points to a fie
record with search-key value K, or to a budet of pointers
i=12,--1, 3 fA, TMTP T- K, a 3. Otherwise k2 Km-i, wherethere are mpointers in 3. 3-41&2K 51-1 T T
the node. Then follow Pm to the child node.
to file records, each record having
search-key value K, Only i tRaat, T fit ME TN
need bucket strudture if searchkey does not form a primary 7K Tr I f the node reached by following the s
pointer above
key. not a leaf node, repeat the above procedure on the
Pn point to next leaf node in search-key order node, and follow the corresponding pointer.

Eventually reach a leaf node. If for some i, key K, = k


follow pointer P to the desired record or bucket. Else
no record with search-key value k exists.

Insertions and deletions to the main file can be handled


efficiently, as the index can be restructured in logarith
mic time las we shall see).

Non-Leaf Nodes in B+-Trees lthere are K search-key values in the file, the path is no
longer than o n{)J.
Non leaf nodes form a mult-level sparse index on the leaf
nodes. For a non-leaf node with m pointers: With 1 million search key values and n 100, at most
All the search-keys in the sub-tree to which P, points are oBsol1,000,000) = 4 nodes are accessed in a lookup. log,(1,000,000) =4 e fn zi
less than K1 - a d-sta fcu fs P, RA K, i 341 4 .
NoTraizaun | 167

value woukd Jp
node ie ehh the rch-key
k aee s aveudh there n the kat noxke
l e to fle and d necesay a Katers mserted

hkey value s nt there then add the record to


e nd Creale a bucket d nersury Then cOFYideie spstpirs
re m u the eat ane unsert ikey value,

air in the ka' nadek


v e git the rode laiong with the new
p t e r ety
ode
ssrC Ay vae pante

ginernac r sited onder


a l e nd he ret n a new node
pars including the
Pace tirst
the n2in
n (HN-E1t i vdg) vad (fradv FrTd«7 fka nITfAe

)i aiks att d aifsy aiitareaate 7 La/2 *t a AAAA cOPT middie wprais


newI D D ard et k be the ieast key value in p.
an e e n t ci e node being spit. if the par.
spit t ànc arccagate the spit further up.
ing r cues proceeds upwards il a node that is j PESE
s cund i e wc cae he root node may be fi a i t wan aran ti rrd uua frfa d r ate
n g e heighe cí te ree by 1.
NTION
e LEAF eve s handied by cOPINC the middle
&T:
PAM|
sahgher eve 1 arcied ty PUSING the mddle

DNSERTION OF KEY'K
t warchkey value to L such that the keys are in
cnder
( l overfirws{

inun (e, COP) snalluest search-key value LJINAL TREE


of terw 1ode to parent rode "P;

peat the Bure split pra edure recursively,


iotc the bTHEL spli, NOT theB tuoe/

PPHH
168bONS
insertion of "Ceariew
B+-Tree bekore and after dress of a data item by computing a function on the search
8+-Tree File Organization B+ 3tfdyra key value.
sobed by using 84-Tree H ET fid7 sA B ata g0 zia feriHashing is an effective technique calculate the direct
Index fle degradation problem s to
lo
cation of a data record on the disk without using the index tfrin
indices
B+tree file organization store 5 B+IE TAAA d ens ika fatR E ,sructure. Hashing uses hash functions with search keys a5
The leaf nodes in a
|parameters to generate the address of a data record.
records, insteeed of pointen
Since records are larger than pointers, the maximum num- i izi sdT aAt zrd 8, fesiga afrsa7A hash file stores data in bucket format. Bucket is considered
a

ber of records that can be stored in a leaf node is less than He, g iy As ¥R TA, 4ie Az 7 launit of storage. Abucket typically stores one complete disk
the mumber of pointers in a nonleaf node. block which'in turn càn store one or more records.
Leafnodes are siquired to be half full. A hash fundtion h is a function from the set of all search
Insertion and deletion are handled in the same way as in A r setva TM TT isa fsy Td ra B+-key values Kto the set of all bucket addresses B.
serdion and deletion of entries in a B+ree index. o We choose a number of buckets to correspond to
the number of search key values we will have
stored in the database.
To perform a lookup on a
o
search key value K, we
compute htK), and search the bucket with that ad-
,

dress.
lf two search keys i andj map to the same address,
because h{K) = h{K), then the bucket at the ad-
dress obtained will contain records with both bki) hki), i Ta
T
seàrch key values.
o In this case we will have to check the search keyY
-Tree Index Files value of every record in the bucket to get the ones
Similar to B+-ree, but B-tvee alows, search-key values to we want

appear only onoe; elimínates redundant storage of search o


Agood hash function gives an average ase lo up
that is a small constant, independent of the num-
B- R E; iA; ber of search keys.
Search keys in nonleaf nodes appear nowhere else in theB.:- FN TI YsrA uT R AN
ree an additional pointer field for each search key fn a . o hope records are distributed uniformly among
We
nonleaf node must be incuded. the buckets.
o The worst hash function maps all keys to the same
bucket
o The best hash function maps all keys to distinct ad-
dresses.
deally, distribution of keys to addresses is uniform and ran
dom.
Suppose we have 26 buckets, and map names beginning
with ith letter of the alphabet to the ith bucket.t
o Problem: this does not give uniform distribution.

B-tree (above) and B+ree (below) on same data Many more names will be mapped to "A" than to "X 37tT "A"
X'.
Typical hash functions perform some operation on
the internal binary machine representations of
characters in a key.
O For example, compute the sum, modulo # of
buckets, of the binary representations of characters T, T5Z
of the search key.
Using this method for 10 buckets (assuming the ith
character in the alphabet is represented by integer

Hashing Hashing are of two types


Index schemes force us to traverse an index structure. Static Hashing
Hashing avoids this. Hashing imvolves computing the ad- i tfn d zri ii t T E NIT Dynamic Hashing
*** *****
Normalization 171
lsshung
Data Buckes
resultant data bucket address will
tne
r hasame. That is the hash function always. Data Record 102
105
for a gen search-key value. 10
$arne address HASH
an address tor tmp_ld 103 =

le, i e generate then it New Record


will atways result in
hash function mod(5)
e

address 3. Here, there wll be no change in ts 3 e zai, a*z ter eai n ti zu. Closed Hlashing
cket 2. tfi
ket address. he output address shall always be
or thrs funcuon. When br cke arefull, then
ts data bucket is allo-
a new
cated for th: same hash result and is linked after the
n the static hashing number of data buckeis in previous onit. This mechanism is known as overtlow
e
rernairs constant throughout. chaining
ofy
Data Bckes
Now, in he 2xample given in the open hashing, a new
Meerut bucket i inserted at the end of 110 buckets and is
Seardh Keys
Dah linked te it.
L100 Aga Data Buckets
101 Lucknow L 102
102 Verana Data Record 105
103F Mathura
erauons
Deradin 10H HASH -
110
110
New Record
insertion- When a new record is inserted into the
table, then we will generate an address for a new
based the hash key and record is stored in
tecord
s2 that location.
on
The prollem with static hashing is that it does not ex-
Searching - when a record needs to be searched,
RT -

TAT fTIE T gà ë at ast n vA ZPdna or shirink dynamically as the size of the database
grows or sh rinks. Dynamic hashing helps us to over
then the same hash function retieves
the bucket where he data is stored.
the address of
come th problem of bucket overilow. Dynamic hasing
Deletion To delete a record, we will first fetch the .fsi-frots
fad
fseitz rà* fay EH TE TÀ ftaië aprovides a mechanism in which data buckets are
feritz aTT fr T7 àard i a a*added ind removed dynamically and on-demand.
PCord which is supposed to be deleted. Then-we' w Dynami
j e l e t e the records tor that address in memory hashing is also known as extended hashing8
Update a recordlo update a record, we will firsz In dynainic hashing hash funcion is made to
produce
a r c h it using a hash function and then the data 3¥I À FÈ TNi a fr a fsid initially. number
3aude salarge of values and only a few are used
e c o r d is updated.
af T fsri T f s i
wJnt to
insert some new
record into he file but tte Ed , "g n
dynarnic hashing, the hash
e

ess of a data bucket generatedin by the


hash function is
NA FT K A 3T T7 I a I TEt E 34 K *
VE duce à iarg: number funcion is made to
pro
of values. For
hree di i ecords B1, 82 and B3. example,
there are
empty, or that addres. This siu-
data already exists zra1Rfza ifrin « faafa z z 3A Td i The hash function
v the static nashing is Known as bucket overfow. o
methods are used
generates Ihree addresses 1001, 0101 and 1110 aB3 I ABA: 1001,0101 a
1110
come this satuatton, lollOwing
-

(1) a s fRrin Tespectivey This


of this adruss- method
of storing considers
only part
) Open Hashing
(2) i f s i n So
especially only first bit to store the data.
7 121Ctosed Hashing it tries li load three of them at addreas 0 and 1.
Open Hashing h(B1)1001 h82) 0101 h83)1110
when a hash function generates an address at which

data is already stored, then the next bucket will be allo-


aterd to it.
hs s also known as linear probing. For exampie,sup
se we need to insert 10 as a new address. The hash T 10Hd 8d i dT FRA 10 110 But the prolem is that no bucket address is remaining
g * for B3 Te bucket has to grow
uHon generates address as 110 tor 10. But tie gen- TI I T E VTÀIFAT1 : TRH c dynamically
to
erated address is already ful. so the system searches r 67 112 THd 10 a d
acomc-dite 83. So it changes the address to have 2
Dits rat:e ihan one bit and then it
updates the existing
rextavailable data bucket 112 and assigns 10 to it. data to n.ne 2 bit address.
Then it tries to accomodate
172DBMS 174 D
83 as htB1) 1001 hB2) 0101 h83) 1110
00
the duplicate values are not
are called unique Index.
placed, such indexes
Duplicate Value 81 7a Normalization 173 in
Unique Index , tad
011 Thus on the basis of the number of columns included, tw
Indexes are of two following types A
10 cat
Simple Index The Indexes created on only one Simple Index-td -an fa fa In
column of table. It means index includes only
a
aaa asc
Now, as we can see that address of B1 and 82 are one column of the table. Such Index is called
changed to reflect the new address and B3 is also in- aiga afstea , 34
Simple Index'. 'Simple Index za the
serted. As the size of the data inceases, it tries to insert
in the existing buckets. If no buckets are available, the
Composite Index - If an Index is based on more Composite Index -aR fFRi de

than one column of a table, it is called 'Composite


number of bits is increased to consider larger address,
and hence increasing the buets. Ifwedelete any record
Index. Index d Composite
and if the data can be stored with lesser buckets, it
Rtete Tdiua sa ITT RCreating Dupicate Index
shrinks the bucket size. It does the opposite of what we RE IT ag uT a E HFI A A Duplicate Index can be created in both
have seen above. This is how a dynamic hashing works. simple or
composte way. The syntax and example of both of these 'Duplicate Index i Simple auan Comnct
are as follows
Composte 9en
Advantages of dynamic hashing
o In this method, the performance does not decreases as o at 7, fran s a T I ta
a ) Creating Simple Duplicate Index - Such Index con (a) Creating Simple Duplicate Index -M FTa
the data grows in the system. It simply increases the
tains only one column of the table. Creat
Syntax CREATE INDEX <IndexName> ON a
size of mermory to accomodate the data. CREATE INDEX <Index Name> Apart
ated irn
o In this method, memory is well uilized as it grows and o a 7,3a * h am ved d Ki - z <TableName> (<ColumnName>);
Table Name> (<olurnn These
shrinks with the data. There will not be any unused Name, also bE
memory. (a)
L CREATE 1HDER 1D_STUDENTS 0
oThis method is good for the dynamic database.
nder created.

Operations
Querying- Look at the depth value of the hash index
o
Querying dn a 7z zH
and use those bits to compute the bucket address.
above and the Update R N TY T t T si I a
update o
-

Update- Perfom a query as In the above example, an index 1DX_STUDENTS is 3TIR 3KTGU T STUDENTS TH Z
data. created on the STUDENTS' table. This index contains
T ldx Stude
Deletlon Perform a locate the desired data o Deletion -
aA ZA ST A T zi catesz »t a only one column of the table 'NAME: So, it is a Simple - NAME FAfa Bi 37: T 7
-

queryto Simple Dup


and delete the same. Duplicate Index in which all the values of the NAME cate Index3, fTHd 'Students ~a NAME
TE
Insertion-Compute the address of the bucket.If the o Insertion z zA zsz vE d column of the table will be sorted in ascending order. Values 3TTEt (Assending) 4
Son zt
bucket is already full then one can add more budkets t sat ardzu F I 3TT Creating Composite Duplicate Index -
If more than (b) Creating Composite Duplicate Index-,
f Dup
or add additional bits the
to hash value. Or,
reaompute
the hash funtion. If there is space in the bucket then
one column are contained in a duplicate index at the cate Index 1 AHtI 5 HH Z
time of creation, such index is called Composite Du- Columns t*afera i, a W TA Compos
just add the data to the bucket plicate Index. Duplicate Index 1 mdi
T FF T rEH EI TA SiT Tit7 a syati qd
One must employ the hashing technique when data is dis fa:
siftë zra i frd *a Hda 3i ATCTu Syntax
crete and random. Hashing is not appropriate in case of CREATE INDEX <IndexName> ON
ordered data and when queries requires a range of data.
<TableName> (<Column1>,<Column2>,
Index Definition in SQL sQL 37 Example:
t is very simple to create index in Orade. The CREATE
INDEXSatementis usedtocreatethe index. On the basis CREATEINDEXT TTH I a Uiacle SO Plu
of the values Indexes are of two types
placed in it, SQL> CREATE INDEX PERSONS_IDEX ON
2 PERSONS (FIRST_NAKE,LAST_HAME);
o Duplicate Index: Few indexes permits to store Duplicate Index: 3T (kclumns
duplicate values in their columns. Such Indexes HT7 (Duplicatevalues) at t aaia 4 rd FI |Index created.
are called Duplicate Indexes. 3 Duplicate Index *TI T I
T5 .

SQL
o Unique Index: The Indexes, where duplicate Unique Index: T fors colunns Et
values are prahibited in columns, ît means, in which (Duplicate values) tT fre Tr i, zuq f

S
******************e***d***vi **** **
174 DBMS
17; nthe above exaMple, index s created for 'PERSONS
with the name PERSOAS_INDEX. t includes 3TU 3TCT 'PERSONS }AH fTN TG R TM OPpin lhe Index Nomalization|175
tabe a,frrI TH Persons-lndex i zu7 A 7
Col The pro of removing an Index related to a
tuo columns of the 1able, FiRST_NAME" and umns-First Name' table i5 a zaTa fozi zi i s y
a "Last-Name' zfztea ti ta called di y;
AST NAME This s nothing but Composite Dupli ze
ing index. Ihe DROP INUEX COmmana DROPINDEX THE
Tm fan a I g fa a a t:
Cate Incex Compasite Duplicate Index used for sB same. The
syntax is as follows:
n the Index, the data ot the column is stored in DROP INDEX
Kending order, by delault. t t is to be sorted in the zTI uf Fa sTTdEt (Descending) 4 I P INDEX <IndexName>; <Index Name>;
dekending order, then 'DESC keyword is used ater Sort E1 8), a Example
he sColumaNanme> at the üme of defining the In- Or cte S01 9s
dex, as shown in the toilowing example: Name> au 'DESC Keywordfrat tiT

Ekample: Todex krop.

Multipl: Key Access


Uptil nov w were having index on single aolumn/primary
key. But wmetimes situations arises where we are re
Creating Unique Index quired t at ess multöple key. Actually it is not ahways nec
essary that tine query s only restricted to primary key or
Apart trom the duplicate index, indexes can also be cre Duplicate Index 3TaiT TAT A TH TH *T TTK single co un n. It may have various needs to see the records
ated in Oracde containing the values without duplicates. Hd,sd Et H7 (Duplicate values) tai AIFT ( in differe nt ombínations of columns. In such cases indexes
These are caled UNIQUE INDEX. UNIQUE INDEX can lowed) T sta UNIQUEINOEX T I UNIQU On prim.cy inglecolumn will degrade the performance of
aso be of both types, Simple and Composite. INDEX t Simple au Compasite ii sYN T Fd ¥he que:y 'ecauUse the table will have huge number of
(a) Simple Unique Index - lí only one column of the rds
(a) Simple Unique Index-afR UNIQUE INDEX ¥| all
index on any one column will efficienty fetch
recor.ls ivhich satisfies the search criteria for indexed
table is considered in UNIQUE INDEX, then such
column. NeN, again it still has to filter the data with other
index is called Simple Unique Index. The syntax
Simple Unique Index E1 T search c ilciia on which we do not have index. Instead of
to create simple" unique index is as fllows
CREATE UNIQUE INDEX <lndexName> CREATE UNIQUE INDEX <Index Namedoing
t
like- this we will use combination of two or more
columns hich are queried to get index, In this way query
ON <Table Name> (<Column Namei|become simple and faster. Multiple key access
ON TableName> (<ColumnName>}; works effi-
ciently when all the columns of the index are uSed in the
Example: query. It wurks efficiently even on larger tables. This is be-
tud
cause, rco1ds are sorted based on the index.
Du
3T (LN0); EXERCISE
iadex creatd.

Multiple Choice Qustions


1. y record has a ****************** **********

uple (6) key field


b) Composite Unique
lndex -
If the UNIQUE IN (6) Compsite Unique Index-R UNIQUE INDEX Ctribute d)value d)
than one columns of the table,
DX contains more
2. a technique used to retrieve records from the
Composite Unique Index. The unique T ii
then it is called Jit.base files on the basis of some key field
svntax 5 as 1ollows:
CREATE UNIQUE INDEX <IndexName> ON ai Hashing b) Indexing (a) Hashing b) dndexing
<TableName> (<Column1>,<Column2>, * tree (d) Static hashing c) B tree d) Staic hashing
3. es of indexing-
Example
(b) Secondary Key
ii Primary Key (o) Secondary Key (aPrimaryKey
QL CEATE UHI QUE LOE raSOKS_IDE ON
lustering (d) All of these (c) Clusteing
2 ERSOHS(ID,PHOE_HO);
4. inix record appears for every search-key value in
Indes created.
th file is called:
(a) Sparse lIndex (b Denise index
Sparse Index (b) Dense Index
() Mulblevel index (d) None of these (c) Mutileve! Irdex
176 DBMS
These techniques are employed to implement mal
tilevel indexing
(a) B-tree (b) 6 vee
h)'tree ta) tree
c) AV tree d) a &b d) a& b
AVL bee
6. It helps in breaking down the Index into several
small indikes (b) - T
(a) Singte-lev () Multi level
(d)
Two levl (d) Many level
I t is an example of multllevel indexlng- a) A vee (b) 8 ree
(a) A' tree (b) B tree
C tree (d) All of these Cuee
Two types of hashing:
al Static (b) Random (a) Static (b) Randor
(d) b&c () Oynamic d)a&c
Dynamic
A hash file stores data in.
a) index (b) bucket (a) index (b) bucket

( block (d) cell ( blodk id) cell


10. Techniques used to handle bucket overflow
a) Open hashing (b) Closed hashing (a) open hashing b) closed h2s ing
(a&b (d) Bucket hashing c akb id) Bucket na hing
Very Short Answer Type Questions :
1. Name the field used to recognize the record
uniquely
2. Name types
ofindexing.
3. What is sparse index ?
4. Give an example of multilevel index.
5. Whatis Bucket? 5. z ?
6. Name the techniques used to óvercome bicket
ovrfiow
Short Answer Type Questions:
1. Define hashing. 1. u
2. Deine indexing.
3. Name types of indexing
4 What is mutblevel indexing? 4. daaRAM a ?
S. Write a short note on statlc and dynamic hashing.
Long Answer Iype Questions :
1 Diom indexing in detail
2. Explain the concept of hashírg
3. Discus the types of hashin
4. What s the index definition in SO
Howcan you create and drop index

You might also like