S t o r a g e a n d F i l e O r g a n i z a t - - PowerPoint PPT Presentation

s t o r a g e a n d f i l e o r g a n i z a t i o n s t o
SMART_READER_LITE
LIVE PREVIEW

S t o r a g e a n d F i l e O r g a n i z a t - - PowerPoint PPT Presentation

S t o r a g e a n d F i l e O r g a n i z a t i o n S t o r a g e a n d F i l e O r g a n i z a t i o n F i l e O r g a n i z a t i o n F i l e O r g a n i z a t i o


slide-1
SLIDE 1

S t

  • r

a g e a n d F i l e O r g a n i z a t i

  • n

S t

  • r

a g e a n d F i l e O r g a n i z a t i

  • n
slide-2
SLIDE 2

1 1 . 2 D a t a b a s e S y s t e m C

  • n

c e p t s

F i l e O r g a n i z a t i

  • n

F i l e O r g a n i z a t i

  • n
  • B

a s i c s

  • A

d a t a b a s e i s a c

  • l

l e c t i

  • n
  • f

fj l e s ,

  • A

fj l e i s a c

  • l

l e c t i

  • n
  • f

r e c

  • r

d s

  • A

r e c

  • r

d ( t u p l e ) i s a c

  • l

l e c t i

  • n
  • f

fj e l d s ( a t t r i b u t e s )

  • F

i l e s a r e s t

  • r

e d

  • n

D i s k s ( t h a t u s e b l

  • c

k s t

  • r

e a d a n d w r i t e )

  • T

w

  • i

m p

  • r

t a n t i s s u e s :

1 . R e p r e s e n t a t i

  • n
  • f

e a c h r e c

  • r

d 2 . G r

  • u

p i n g / O r d e r i n g

  • f

r e c

  • r

d s a n d s t

  • r

a g e i n b l

  • c

k s

slide-3
SLIDE 3

1 1 . 3 D a t a b a s e S y s t e m C

  • n

c e p t s

F i l e O r g a n i z a t i

  • n

F i l e O r g a n i z a t i

  • n
  • G
  • a

l a n d c

  • n

s i d e r a t i

  • n

s :

  • C
  • m

p a c t n e s s

  • O

v e r h e a d

  • f

i n s e r t i

  • n

/ d e l e t i

  • n
  • R

e t r i e v a l s p e e d

  • s
  • m

e t i m e s w e p r e f e r t

  • b

r i n g m

  • r

e t u p l e s t h a n n e c e s s a r y i n t

  • M

M a n d u s e C P U t

  • fj

l t e r

  • u

t t h e u n n e c e s s a r y

  • n

e s !

slide-4
SLIDE 4

1 1 . 4 D a t a b a s e S y s t e m C

  • n

c e p t s

R e c

  • r

d R e p r e s e n t a t i

  • n

R e c

  • r

d R e p r e s e n t a t i

  • n
  • F

i x e d

  • L

e n g t h R e c

  • r

d s

  • E

x a m p l e A c c

  • u

n t ( a c c

  • n

u m b e r c h a r ( 1 ) , b r a n c h

  • n

a m e c h a r ( 2 ) , b a l a n c e r e a l ) E a c h r e c

  • r

d i s 3 8 b y t e s . S t

  • r

e t h e m s e q u e n t i a l l y ,

  • n

e a f t e r t h e

  • t

h e r R e c

  • r

d 1 a t p

  • s

i t i

  • n

, r e c

  • r

d 2 a t p

  • s

i t i

  • n

3 8 , r e c

  • r

d 3 a t p

  • s

i t i

  • n

7 6 e t c C

  • mp

a c t n e s s ( 3 5 b y t e s )

slide-5
SLIDE 5

1 1 . 5 D a t a b a s e S y s t e m C

  • n

c e p t s

F i x e d

  • L

e n g t h R e c

  • r

d s F i x e d

  • L

e n g t h R e c

  • r

d s

  • S

i m p l e a p p r

  • a

c h :

  • S

t

  • r

e r e c

  • r

d i s t a r t i n g f r

  • m

b y t e n  ( i – 1 ) , w h e r e n i s t h e s i z e

  • f

e a c h r e c

  • r

d .

  • R

e c

  • r

d a c c e s s i s s i m p l e b u t r e c

  • r

d s m a y c r

  • s

s b l

  • c

k s

  • M
  • d

i fj c a t i

  • n

: d

  • n
  • t

a l l

  • w

r e c

  • r

d s t

  • c

r

  • s

s b l

  • c

k b

  • u

n d a r i e s

  • I

n s e r t i

  • n
  • f

r e c

  • r

d i : A d d a t t h e e n d

  • D

e l e t i

  • n
  • f

r e c

  • r

d i : T w

  • a

l t e r n a t i v e s :

  • m
  • v

e r e c

  • r

d s :

  • i

+ 1 , . . . , n t

  • i

, . . . , n – 1

  • M
  • v

e r e c

  • r

d n t

  • p
  • s

i t i

  • n

i

  • d
  • n
  • t

m

  • v

e r e c

  • r

d s , b u t l i n k a l l f r e e r e c

  • r

d s

  • n

a f r e e l i s t

slide-6
SLIDE 6

1 1 . 6 D a t a b a s e S y s t e m C

  • n

c e p t s

F r e e L i s t s F r e e L i s t s

  • 2

n d

a p p r

  • a

c h : F L R w i t h F r e e L i s t s

  • S

t

  • r

e t h e a d d r e s s

  • f

t h e fj r s t d e l e t e d r e c

  • r

d i n t h e fj l e h e a d e r .

  • U

s e t h i s fj r s t r e c

  • r

d t

  • s

t

  • r

e t h e a d d r e s s

  • f

t h e s e c

  • n

d d e l e t e d r e c

  • r

d , a n d s

  • n
  • C

a n t h i n k

  • f

t h e s e s t

  • r

e d a d d r e s s e s a s p

  • i

n t e r s s i n c e t h e y “ p

  • i

n t ” t

  • t

h e l

  • c

a t i

  • n
  • f

a r e c

  • r

d .

B e t t e r h a n d l i n g i n s / d e l L e s s c

  • m

p a c t

slide-7
SLIDE 7

1 1 . 7 D a t a b a s e S y s t e m C

  • n

c e p t s

V a r i a b l e

  • L

e n g t h R e c

  • r

d s V a r i a b l e

  • L

e n g t h R e c

  • r

d s

  • 3

r d

a p p r

  • a

c h : V a r i a b l e

  • l

e n g t h r e c

  • r

d s a r i s e i n d a t a b a s e s y s t e m s i n s e v e r a l w a y s :

  • S

t

  • r

a g e

  • f

m u l t i p l e r e c

  • r

d t y p e s i n a fj l e .

  • R

e c

  • r

d t y p e s t h a t a l l

  • w

v a r i a b l e l e n g t h s f

  • r
  • n

e

  • r

m

  • r

e fj e l d s .

  • R

e c

  • r

d t y p e s t h a t a l l

  • w

r e p e a t i n g fj e l d s

  • r

m u l t i v a l u e d a t t r i b u t e .

  • B

y t e s t r i n g r e p r e s e n t a t i

  • n
  • A

t t a c h a n e n d

  • f
  • r

e c

  • r

d ( ) c

  • n

t r

  • l

c h a r a c t e r t

  • t

h e e n d

  • f

e a c h r e c

  • r

d

  • D

i ffj c u l t y w i t h d e l e t i

  • n

( l e a v e s h

  • l

e s )

  • D

i ffj c u l t y w i t h g r

  • w

t h

4

  

Field Count R 1 R 2 R 3

slide-8
SLIDE 8

1 1 . 8 D a t a b a s e S y s t e m C

  • n

c e p t s

V a r i a b l e

  • L

e n g t h R e c

  • r

d s : S l

  • t

t e d P a g e V a r i a b l e

  • L

e n g t h R e c

  • r

d s : S l

  • t

t e d P a g e S t r u c t u r e S t r u c t u r e

  • 4

t h

a p p r

  • a

c h V L R

  • S

P

  • S

l

  • t

t e d p a g e h e a d e r c

  • n

t a i n s :

  • n

u m b e r

  • f

r e c

  • r

d e n t r i e s

  • e

n d

  • f

f r e e s p a c e i n t h e b l

  • c

k

  • l
  • c

a t i

  • n

a n d s i z e

  • f

e a c h r e c

  • r

d

  • R

e c

  • r

d s s t

  • r

e d a t t h e b

  • t

t

  • m
  • f

t h e p a g e

  • E

x t e r n a l t u p l e p

  • i

n t e r s p

  • i

n t t

  • r

e c

  • r

d p t r s :

  • r

e c

  • i

d = < p a g e

  • i

d , s l

  • t

# >

slide-9
SLIDE 9

1 1 . 9 D a t a b a s e S y s t e m C

  • n

c e p t s

Page i Rid = (i,N) Rid = (i,2) Rid = (i,1)

Pointer to start

  • f free

space

SLOT DIRECTORY

N . . . 2 1 20 16 24

N # slots

I n s e r t i

  • n

: 1 ) U s e F r e e S p a c e P

  • i

n t e r ( F P ) t

  • fj

n d s p a c e a n d i n s e r t 2 ) F i n d a v a i l a b l e p t r i n t h e d i r e c t

  • r

y (

  • r

c r e a t e a n e w

  • n

e ) 3 ) a d j u s t F P a n d n u m b e r

  • f

r e c

  • r

d s D e l e t i

  • n

?

slide-10
SLIDE 10

1 1 . 1 D a t a b a s e S y s t e m C

  • n

c e p t s

V a r i a b l e

  • L

e n g t h R e c

  • r

d s ( C

  • n

t . ) V a r i a b l e

  • L

e n g t h R e c

  • r

d s ( C

  • n

t . )

  • F

i x e d

  • l

e n g t h r e p r e s e n t a t i

  • n

:

  • r

e s e r v e d s p a c e

  • p
  • i

n t e r s

  • 5

t h

a p p r

  • a

c h : F i x e d L i m i t R e c

  • r

d s ( f

  • r

V L R )

  • R

e s e r v e d s p a c e – c a n u s e fj x e d

  • l

e n g t h r e c

  • r

d s

  • f

a k n

  • w

n m a x i m u m l e n g t h ; u n u s e d s p a c e i n s h

  • r

t e r r e c

  • r

d s fj l l e d w i t h a n u l l

  • r

e n d

  • f
  • r

e c

  • r

d s y m b

  • l

.

slide-11
SLIDE 11

1 1 . 1 1 D a t a b a s e S y s t e m C

  • n

c e p t s

P

  • i

n t e r M e t h

  • d

P

  • i

n t e r M e t h

  • d
  • 6

t h

a p p r

  • a

c h : P

  • i

n t e r m e t h

  • d
  • P
  • i

n t e r m e t h

  • d
  • A

v a r i a b l e

  • l

e n g t h r e c

  • r

d i s r e p r e s e n t e d b y a l i s t

  • f

fj x e d

  • l

e n g t h r e c

  • r

d s , c h a i n e d t

  • g

e t h e r v i a p

  • i

n t e r s .

  • C

a n b e u s e d e v e n i f t h e m a x i m u m r e c

  • r

d l e n g t h i s n

  • t

k n

  • w

n

slide-12
SLIDE 12

1 1 . 1 2 D a t a b a s e S y s t e m C

  • n

c e p t s

P

  • i

n t e r M e t h

  • d

( C

  • n

t . ) P

  • i

n t e r M e t h

  • d

( C

  • n

t . )

  • D

i s a d v a n t a g e t

  • p
  • i

n t e r s t r u c t u r e ; s p a c e i s w a s t e d i n a l l r e c

  • r

d s e x c e p t t h e fj r s t i n a c h a i n .

  • S
  • l

u t i

  • n

i s t

  • a

l l

  • w

t w

  • k

i n d s

  • f

b l

  • c

k i n fj l e :

  • A

n c h

  • r

b l

  • c

k – c

  • n

t a i n s t h e fj r s t r e c

  • r

d s

  • f

c h a i n

  • O

v e r fm

  • w

b l

  • c

k – c

  • n

t a i n s r e c

  • r

d s

  • t

h e r t h a n t h

  • s

e t h a t a r e t h e fj r s t r e c

  • r

d s

  • f

c h a i n s .

slide-13
SLIDE 13

1 1 . 1 3 D a t a b a s e S y s t e m C

  • n

c e p t s

O r d e r i n g a n d G r

  • u

p i n g r e c

  • r

d s O r d e r i n g a n d G r

  • u

p i n g r e c

  • r

d s

  • I

s s u e # 1 :

  • I

n w h a t

  • r

d e r w e p l a c e r e c

  • r

d s i n a b l

  • c

k ? 1 .H e a p t e c h n i q u e : a s s i g n a n y w h e r e t h e r e i s s p a c e 2 .O r d e r e d t e c h n i q u e : m a i n t a i n a n

  • r

d e r

  • n

s

  • m

e a t t r i b u t e

S

  • ,

w e c a n u s e b i n a r y s e a r c h i f s e l e c t i

  • n
  • n

t h i s a t t r i b u t e .

slide-14
SLIDE 14

1 1 . 1 4 D a t a b a s e S y s t e m C

  • n

c e p t s

S e q u e n t i a l F i l e O r g a n i z a t i

  • n

S e q u e n t i a l F i l e O r g a n i z a t i

  • n
  • S

u i t a b l e f

  • r

a p p l i c a t i

  • n

s t h a t r e q u i r e s e q u e n t i a l p r

  • c

e s s i n g

  • f

t h e e n t i r e fj l e

  • T

h e r e c

  • r

d s i n t h e fj l e a r e

  • r

d e r e d b y a s e a r c h

  • k

e y

slide-15
SLIDE 15

1 1 . 1 5 D a t a b a s e S y s t e m C

  • n

c e p t s

S e q u e n t i a l F i l e O r g a n i z a t i

  • n

( C

  • n

t . ) S e q u e n t i a l F i l e O r g a n i z a t i

  • n

( C

  • n

t . )

  • D

e l e t i

  • n

– u s e p

  • i

n t e r c h a i n s

  • I

n s e r t i

  • n

– l

  • c

a t e t h e p

  • s

i t i

  • n

w h e r e t h e r e c

  • r

d i s t

  • b

e i n s e r t e d

  • i

f t h e r e i s f r e e s p a c e i n s e r t t h e r e

  • i

f n

  • f

r e e s p a c e , i n s e r t t h e r e c

  • r

d i n a n

  • v

e r fm

  • w

b l

  • c

k

  • I

n e i t h e r c a s e , p

  • i

n t e r c h a i n m u s t b e u p d a t e d

  • N

e e d t

  • r

e

  • r

g a n i z e t h e fj l e f r

  • m

t i m e t

  • t

i m e t

  • r

e s t

  • r

e s e q u e n t i a l

  • r

d e r

slide-16
SLIDE 16

1 1 . 1 6 D a t a b a s e S y s t e m C

  • n

c e p t s

C l u s t e r i n g F i l e O r g a n i z a t i

  • n

C l u s t e r i n g F i l e O r g a n i z a t i

  • n
  • S

i m p l e fj l e s t r u c t u r e s t

  • r

e s e a c h r e l a t i

  • n

i n a s e p a r a t e fj l e

  • C

a n i n s t e a d s t

  • r

e s e v e r a l r e l a t i

  • n

s i n

  • n

e fj l e u s i n g a c l u s t e r i n g fj l e

  • r

g a n i z a t i

  • n
  • e

. g . , c l u s t e r i n g

  • r

g a n i z a t i

  • n
  • f

c u s t

  • m

e r a n d d e p

  • s

i t

  • r

:

  • g
  • d

f

  • r

q u e r i e s i n v

  • l

v i n g d e p

  • s

i t

  • r

a c c

  • u

n t , a n d f

  • r

q u e r i e s i n v

  • l

v i n g

  • n

e s i n g l e c u s t

  • m

e r a n d h i s a c c

  • u

n t s

  • b

a d f

  • r

q u e r i e s i n v

  • l

v i n g

  • n

l y c u s t

  • m

e r

  • r

e s u l t s i n v a r i a b l e s i z e r e c

  • r

d s

S E L E C T

a c c

  • u

n t

  • n

u m b e r , c u s t

  • m

e r

  • n

a m e

F R O M d e p

  • s

i t

  • r

d , a c c

  • u

n t a WH E R E

d . c u s t

  • m

e r

  • n

a m e = a . c u s t

  • m

e r

  • n

a m e

slide-17
SLIDE 17

1 1 . 1 7 D a t a b a s e S y s t e m C

  • n

c e p t s

F i l e

  • r

g a n i z a t i

  • n

F i l e

  • r

g a n i z a t i

  • n
  • I

s s u e # 2 : I n w h i c h b l

  • c

k s s h

  • u

l d r e c

  • r

d s b e p l a c e d M a n y a l t e r n a t i v e s e x i s t , e a c h i d e a l f

  • r

s

  • m

e s i t u a t i

  • n

, a n d n

  • t

s

  • g
  • d

i n

  • t

h e r s :

  • H

e a p fj l e s : A d d a t t h e e n d

  • f

t h e fj l e . S u i t a b l e w h e n t y p i c a l a c c e s s i s a fj l e s c a n r e t r i e v i n g a l l r e c

  • r

d s .

  • S
  • r

t e d F i l e s : K e e p t h e p a g e s

  • r

d e r e d . B e s t i f r e c

  • r

d s m u s t b e r e t r i e v e d i n s

  • m

e

  • r

d e r ,

  • r
  • n

l y a ` r a n g e ’

  • f

r e c

  • r

d s i s n e e d e d .

  • H

a s h e d F i l e s : G

  • d

f

  • r

e q u a l i t y s e l e c t i

  • n

s . A s s i g n r e c

  • r

d s t

  • b

l

  • c

k s a c c

  • r

d i n g t

  • t

h e i r v a l u e f

  • r

s

  • m

e a t t r i b u t e

slide-18
SLIDE 18

1 1 . 1 8 D a t a b a s e S y s t e m C

  • n

c e p t s

D a t a D i c t i

  • n

a r y S t

  • r

a g e D a t a D i c t i

  • n

a r y S t

  • r

a g e

  • I

n f

  • r

m a t i

  • n

a b

  • u

t r e l a t i

  • n

s

  • n

a m e s

  • f

r e l a t i

  • n

s

  • n

a m e s a n d t y p e s

  • f

a t t r i b u t e s

  • f

e a c h r e l a t i

  • n
  • n

a m e s a n d d e fj n i t i

  • n

s

  • f

v i e w s

  • i

n t e g r i t y c

  • n

s t r a i n t s

  • U

s e r a n d a c c

  • u

n t i n g i n f

  • r

m a t i

  • n

, i n c l u d i n g p a s s w

  • r

d s

  • S

t a t i s t i c a l a n d d e s c r i p t i v e d a t a

  • n

u m b e r

  • f

t u p l e s i n e a c h r e l a t i

  • n
  • P

h y s i c a l fj l e

  • r

g a n i z a t i

  • n

i n f

  • r

m a t i

  • n
  • H
  • w

r e l a t i

  • n

i s s t

  • r

e d ( s e q u e n t i a l / h a s h / …)

  • P

h y s i c a l l

  • c

a t i

  • n
  • f

r e l a t i

  • n
  • p

e r a t i n g s y s t e m fj l e n a m e

  • r
  • d

i s k a d d r e s s e s

  • f

b l

  • c

k s c

  • n

t a i n i n g r e c

  • r

d s

  • f

t h e r e l a t i

  • n
  • I

n f

  • r

m a t i

  • n

a b

  • u

t i n d i c e s

D a t a d i c t i

  • n

a r y ( a l s

  • c

a l l e d s y s t e m c a t a l

  • g

) s t

  • r

e s m e t a d a t a : t h a t i s , d a t a a b

  • u

t d a t a , s u c h a s

slide-19
SLIDE 19

1 1 . 1 9 D a t a b a s e S y s t e m C

  • n

c e p t s

D a t a d i c t i

  • n

a r y s t

  • r

a g e D a t a d i c t i

  • n

a r y s t

  • r

a g e

  • S

t

  • r

e d a s t a b l e s ! !

  • E
  • R

d i a g r a m ?

  • R

e l a t i

  • n

s , a t t r i b u t e s , d

  • m

a i n s

  • E

a c h r e l a t i

  • n

h a s n a m e , s

  • m

e a t t r i b u t e s

  • E

a c h a t t r i b u t e h a s n a m e , l e n g t h a n d d

  • m

a i n

  • A

l s

  • ,

v i e w s , i n t e g r i t y c

  • n

s t r a i n t s , i n d i c e s

  • U

s e r i n f

  • (

a u t h

  • r

i z a t i

  • n

s e t c )

  • s

t a t i s t i c s

slide-20
SLIDE 20

1 1 . 2 D a t a b a s e S y s t e m C

  • n

c e p t s

relation name attribute A-name has 1 N domain position

slide-21
SLIDE 21

1 1 . 2 1 D a t a b a s e S y s t e m C

  • n

c e p t s

D a t a D i c t i

  • n

a r y S t

  • r

a g e ( C

  • n

t . ) D a t a D i c t i

  • n

a r y S t

  • r

a g e ( C

  • n

t . )

  • A

p

  • s

s i b l e c a t a l

  • g

r e p r e s e n t a t i

  • n

:

R e l a t i

  • n
  • m

e t a d a t a = ( r e l a t i

  • n
  • n

a m e , n u m b e r

  • f
  • a

t t r i b u t e s , s t

  • r

a g e

  • r

g a n i z a t i

  • n

, l

  • c

a t i

  • n

) A t t r i b u t e

  • m

e t a d a t a = ( a t t r i b u t e

  • n

a m e , r e l a t i

  • n
  • n

a m e , d

  • m

a i n

  • t

y p e , p

  • s

i t i

  • n

, l e n g t h ) U s e r

  • m

e t a d a t a = ( u s e r

  • n

a m e , e n c r y p t e d

  • p

a s s w

  • r

d , g r

  • u

p ) I n d e x

  • m

e t a d a t a = ( i n d e x

  • n

a m e , r e l a t i

  • n
  • n

a m e , i n d e x

  • t

y p e , i n d e x

  • a

t t r i b u t e s ) V i e w

  • m

e t a d a t a = ( v i e w

  • n

a m e , d e fj n i t i

  • n

)