C S C I 1 2 7 0 I n t r o d u c t i o n t o D - - PowerPoint PPT Presentation

c s c i 1 2 7 0 i n t r o d u c t i o n t o d a t a b a s
SMART_READER_LITE
LIVE PREVIEW

C S C I 1 2 7 0 I n t r o d u c t i o n t o D - - PowerPoint PPT Presentation

C S C I 1 2 7 0 I n t r o d u c t i o n t o D a t a b a s e S y s t e ms w i t h t h a n k s t o P r o f . G e o r g e K o l l i o s , B o s t o n U n i v e r s i t y


slide-1
SLIDE 1

1 . 1

C S C I 1 2 7 I n t r

  • d

u c t i

  • n

t

  • D

a t a b a s e S y s t e ms

w i t h t h a n k s t

  • P

r

  • f

. G e

  • r

g e K

  • l

l i

  • s

, B

  • s

t

  • n

U n i v e r s i t y P r

  • f

. M i t c h C h e r n i a c k , B r a n d e i s U n i v e r s i t y P r

  • f

. A v i S i l b e r s c h a t z , Y a l e U n i v e r s i t y

slide-2
SLIDE 2

1 . 2

Wh a t i s a D a t a b a s e S y s t e m?

 D

a t a b a s e : A v e r y l a r g e c

  • l

l e c t i

  • n
  • f

r e l a t e d d a t a

 M

  • d

e l s a r e a l w

  • r

l d e n t e r p r i s e :

 E n t i t i e s

  • L

e a g u e : T e a m s , p l a y e r s , g a m e s

  • U

n i v e r s i t y : S t u d e n t s , p r

  • f

e s s

  • r

s , b

  • k

s , c

  • u

r s e s  R e l a t i

  • n

s h i p s

  • T

h e P a t r i

  • t

s a r e p l a y i n g i n t h e S u p e r b

  • w

l  D

B M S ( D a t a b a s e M a n a g e m e n t S y s t e m ) : A s

  • f

t w a r e s y s t e m t h a t c a n b e u s e d t

  • s

t

  • r

e , m a n a g e , r e t r i e v e a n d t r a n s f

  • r

m d a t a f r

  • m

a d a t a b a s e .

 D

a t a b a s e S y s t e m : D B M S + d a t a ( + a p p l i c a t i

  • n

s )

slide-3
SLIDE 3

1 . 3

Wh y S t u d y D a t a b a s e s ?

 S

h i f t f r

  • m

c

  • m

p u t a t i

  • n

t

  • i

n f

  • r

m a t i

  • n

 A l w a y s t r u e f

  • r

c

  • r

p

  • r

a t e c

  • m

p u t i n g  S c i e n t i fj c d a t a s e t s :

  • A

s t r

  • n
  • m

y

  • B

i

  • l
  • g

y

  • P

a r t i c l e P h y s i c s  T h e We b

 D

B M S e n c

  • m

p a s s e s m u c h

  • f

C S i n a p r a c t i c a l d i s c i p l i n e

O p e r a t i n g s y s t e m s L a n g u a g e s D i s t r i b u t e d s y s t e m s P e r f

  • r

m a n c e T h e

  • r

y A I

H i g h

  • p

a y i n g j

  • b

s ! ! !

  • J

O B S !

slide-4
SLIDE 4

1 . 4

Wh y D a t a b a s e s ?

 Wh

y n

  • t

s t

  • r

e e v e r y t h i n g i n fm a t fj l e s ?

i . e . , u s e t h e fj l e s y s t e m

  • f

t h e O S : c h e a p , s i m p l e … [

N a me , C

  • u

r s e , G r a d e ] J

  • h

n S m i t h , C S 2 2 , B ; M i k e S t

  • n

e b r a k e r , C S 1 2 3 , A ; J i m G r a y , C S 1 2 7 , A ; J

  • h

n S m i t h , C S 2 2 7 , B + ;

…………………

S i m p l e ? Y e s , b u t n

  • t

s c a l a b l e …

H a v e t

  • s

c a n a n d r e p a r s e t h e fj l e

  • n

e v e r y a c c e s s

. T h i s i s h

  • w

t h i n g s w e r e i n t h e “ B a d O l d D a y s ”

F i l e s y s t e m d

  • e

s n

  • t

k n

  • w

e v e n t h i s

.

slide-5
SLIDE 5

1 . 5

S c a l a b i l i t y

 Wh

i l e y

  • u

m i g h t b u i l d a d a t a b a s e t

  • s

t

  • r

e y

  • u

r f a v

  • r

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

  • t

t h e i n t e r e s t i n g c a s e .

 M

  • d

e r n D B M S ’ s a r e d e s i g n e d t

  • s

c a l e

( i . e . , > > a t e r a b y t e )

M u s t b e w e l l

  • p

t i m i z e d

  • n

a s i n g l e n

  • d

e M u s t b e a b l e t

  • e

x e c u t e

  • n

1 ’ s

  • r

1 ’ s

  • f

n

  • d

e s .

slide-6
SLIDE 6

1 . 6

D B M S D r i v e r s S

  • m

e d a t a i s : l

  • n

g

  • l

i v e d = > c h a n g e s

  • f

t e n = > m u s t w i t h s t a n d f a i l u r e s s h a r e d b e t w e e n d i fg e r e n t u s e r s / a p p l i c a t i

  • n

s

D B

A p p l 1 A p p l 2 A p p l 4 A p p l 3

slide-7
SLIDE 7

1 . 7

S t

  • r

a g e P r

  • b

l e ms

 D

a t a r e d u n d a n c y a n d i n c

  • n

s i s t e n c y

  • M

u l t i p l e fj l e f

  • r

m a t s ,

  • d

u p l i c a t i

  • n
  • f

i n f

  • r

m a t i

  • n

i n d i fg e r e n t fj l e s

N a me , C

  • u

r s e , E ma i l , G r a d e N a me , E ma i l , C

  • u

r s e , G r a d e

J

  • h

n S m i t h , C S 1 1 2 , j s @c s . b u . e d u , B M i k e S t

  • n

e b r a k e r , m s @c s . b u . e d u , C S 2 3 4 , A J i m G r a y , C S 5 6 , j g @c s . b u . e d u , A J . S m i t h , j s @c s . b u . e d u , C S 5 6 , B + J

  • h

n S m i t h , C S 5 6 , j s @c s . b u . e d u , B +

Wh y i s t h i s a p r

  • b

l e m ?

  • Wa

s t e d s p a c e ( ? )

  • P
  • t

e n t i a l i n c

  • n

s i s t e n c i e s ( e . g . , m u l t i p l e c

  • n

v e n t i

  • n

s , J

  • h

n S m i t h v s S m i t h J . )

slide-8
SLIDE 8

1 . 8

R e t r i e v a l P r

  • b

l e ms

 D

a t a r e t r i e v a l ( Q u e r y ) :

 F i n d t h e s t u d e n t s w h

  • t
  • k

C S 5 6  F i n d t h e s t u d e n t s w i t h G P A > 3 . 5

F

  • r

e v e r y q u e r y w e w

  • u

l d n e e d t

  • w

r i t e a p r

  • g

r a m ! E a c h p r

  • g

r a m w

  • u

l d r e a d t h e w h

  • l

e fj l e .

 We

n e e d t h e r e t r i e v a l t

  • b

e :

 E a s y t

  • w

r i t e  E x e c u t e d e ffj c i e n t l y

slide-9
SLIDE 9

1 . 9

D a t a I n t e g r i t y

 D

a t a I n t e g r i t y i n fm a t fj l e m

  • d

e l

 P

  • r

s u p p

  • r

t f

  • r

s h a r i n g :

  • P

r e v e n t s i m u l t a n e

  • u

s m

  • d

i fj c a t i

  • n

s  P

  • r

c

  • p

i n g m e c h a n i s m s f

  • r

s y s t e m c r a s h e s  N

  • m

e a n s

  • f

P r e v e n t i n g D a t a E n t r y E r r

  • r

s ( c h e c k s m u s t b e h a r d

  • c
  • d

e d i n t h e p r

  • g

r a m s )  S e c u r i t y p r

  • b

l e m s  D

a t a b a s e s y s t e m s

  • fg

e r s

  • l

u t i

  • n

s t

  • a

l l

  • f

t h e a b

  • v

e p r

  • b

l e m s

slide-10
SLIDE 10

1 . 1

E v

  • l

u t i

  • n
  • f

d a t a

 L

  • n

g

  • l

i v e d d a t a  E v

  • l

u t i

  • n

 Wh

a t h a p p e n s i f I n e e d t

  • c

h a n g e h

  • w

t h e d a t a i s s t

  • r

e d ? A c c e s s p a t t e r n s c h a n g e T u n i n g

 S

h

  • u

l d n

  • t

h a v e t

  • r

e

  • w

r i t e a l l m y a p p l i c a t i

  • n

s .

 S

  • l

u t i

  • n

: D a t a i n d e p e n d e n c e !

slide-11
SLIDE 11

1 . 1 1

D a t a O r g a n i z a t i

  • n

 D

a t a M

  • d

e l s

: a f r a m e w

  • r

k f

  • r

d e s c r i b i n g

 d a t a

  • b

j e c t s  d a t a r e l a t i

  • n

s h i p s  d a t a s e m a n t i c s  d a t a c

  • n

s t r a i n t s  P

r e s e n t s p r i m i t i v e s f

  • r

 R e p r e s e n t i n g D a t a  D a t a D e fj n i t i

  • n

L a n g u a g e ( D D L )  M a n i p u l a t i n g D a t a  D a t a M a n i p u l a t i

  • n

L a n g u a g e ( D M L )  We

w i l l c

  • n

c e n t r a t e

  • n

t h e r e l a t i

  • n

a l mo d e l

 O

t h e r m

  • d

e l s :

 E n t i t y

  • R

e l a t i

  • n

s h i p mo d e l ( w e w i l l d i s c u s s )  o b j e c t

  • r

i e n t e d m

  • d

e l  s e m i

  • s

t r u c t u r e d d a t a m

  • d

e l s , X M L  A r r a y d a t a m

  • d

e l

slide-12
SLIDE 12

1 . 1 2

D a t a b a s e S c h e ma

 S

i m i l a r t

  • t

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

  • g

r a m m i n g l a n g u a g e s

 S

c h e ma – t h e s t r u c t u r e

  • f

t h e d a t a b a s e  e . g . , t h e d a t a b a s e c

  • n

s i s t s

  • f

i n f

  • r

m a t i

  • n

a b

  • u

t a s e t

  • f

c u s t

  • m

e r s a n d a c c

  • u

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

  • n

s h i p b e t w e e n t h e m  E x p r e s s e d i n s

  • m

e d a t a m

  • d

e l ( D D L )  O c c u r s a t m u l t i p l e l e v e l s

  • L
  • g

i c a l s c h e ma : d a t a b a s e d e s i g n a t t h e l

  • g

i c a l l e v e l

  • P

h y s i c a l s c h e ma : d a t a b a s e d e s i g n a t t h e p h y s i c a l l e v e l

slide-13
SLIDE 13

1 . 1 3

R e l a t i

  • n

a l M

  • d

e l

 E

x a m p l e

  • f

t a b u l a r d a t a i n t h e r e l a t i

  • n

a l m

  • d

e l

c u s t

  • me

r

  • n

a me C u s t

  • me

r

  • i

d c u s t

  • me

r

  • s

t r e e t c u s t

  • me

r

  • c

i t y a c c

  • u

n t

  • n

u mb e r J

  • h

n s

  • n

S m i t h J

  • h

n s

  • n

J

  • n

e s S m i t h 1 9 2

  • 8

3

  • 7

4 6 5 1 9

  • 2

8

  • 3

7 4 6 1 9 2

  • 8

3

  • 7

4 6 5 3 2 1

  • 1

2

  • 3

1 2 3 1 9

  • 2

8

  • 3

7 4 6 A l m a N

  • r

t h A l m a M a i n N

  • r

t h P a l

  • A

l t

  • R

y e P a l

  • A

l t

  • H

a r r i s

  • n

R y e A

  • 1

1 A

  • 2

1 5 A

  • 2

1 A

  • 2

1 7 A

  • 2

1 A t t r i b u t e s

K e y

S c h e m a = C u s t

  • me

r ( C u s t

  • m

e r

  • i

d , c u s t

  • m

e r

  • n

a m e , c u s t

  • m

e r

  • s

t r e e t , c u s t

  • m

e r

  • c

i t y , a c c

  • u

n t

  • n

u m b e r ) T h i s w h

  • l

e t a b l e i s a n i n s t a n c e

  • f

t h e C u s t

  • m

e r s c h e m a .

slide-14
SLIDE 14

1 . 1 4

L e v e l s

  • f

D a t a M

  • d

e l i n g

 L

  • g

i c a l l e v e l : d e s c r i b e s d a t a s t

  • r

e d i n d a t a b a s e , a n d t h e r e l a t i

  • n

s h i p s a m

  • n

g t h e d a t a .

t y p e c u s t

  • m

e r = r e c

  • r

d n a m e : s t r i n g ; s t r e e t : s t r i n g ; c i t y : i n t e g e r ; e n d ;

 P

h y s i c a l l e v e l : d e s c r i b e s h

  • w

a r e c

  • r

d i s s t

  • r

e d .

 S

  • r

t i n g , p a g e

  • a

l i g n m e n t , i n d e x e s  A

l s

  • ,

V i e w l e v e l : a p p l i c a t i

  • n

p r

  • g

r a m s h i d e d e t a i l s

  • f

d a t a t y p e s . V i e w s c a n a l s

  • h

i d e i n f

  • r

m a t i

  • n

( e . g . , s a l a r y ) f

  • r

s e c u r i t y p u r p

  • s

e s .

slide-15
SLIDE 15

1 . 1 5

V i e w

  • f

D a t a

A l

  • g

i c a l a r c h i t e c t u r e f

  • r

a d a t a b a s e s y s t e m D a t a i n d e p e n d e n c e !

slide-16
SLIDE 16

1 . 1 6

D a t a r e t r i e v a l

 Q

u e r i e s Q u e r y = D e c l a r a t i v e d a t a r e t r i e v a l

d e s c r i b e s w h a t d a t a t

  • r

e t r i e v e , n

  • t

h

  • w

t

  • r

e t r i e v e i t E x . G i v e m e t h e s t u d e n t s w i t h G P A > 3 . 5 v s S c a n t h e s t u d e n t fj l e a n d r e t r i e v e t h e r e c

  • r

d s w i t h G P A > 3 . 5

 Wh

y ?

1 . E a s i e r t

  • w

r i t e 2 . M

  • r

e e ffj c i e n t t

  • e

x e c u t e ( w h y ? ) 3 . M

  • r

e a m e n a b l e t

  • c

h a n g e ( c r e a t e / d r

  • p

a n i n d e x )

slide-17
SLIDE 17

1 . 1 7

D a t a r e t r i e v a l

 Q

u e r y O p t i m i z e r

“ c

  • m

p i l e r ” f

  • r

q u e r i e s ( a k a “ D M L C

  • m

p i l e r ” ) Q u e r y P l a n e q u i v a l e n t t

  • A

s s e m b l y L a n g u a g e P r

  • g

r a m

O p t i m i z e r c a n d

  • b

e t t e r Wi t h d e c l a r a t i v e q u e r i e s :

1 . A l g

  • r

i t h m i c Q u e r y ( e . g . , i n C ) ⇒ 1 P l a n t

  • c

h

  • s

e f r

  • m

2 . D e c l a r a t i v e Q u e r y ( e . g . , i n S Q L ) ⇒ n P l a n s t

  • c

h

  • s

e f r

  • m

Q u e r y O p t i m i z e r Q u e r y E v a l u a t

  • r

Q u e r y P l a n D a t a

Q u e r y P r

  • c

e s s

  • r
slide-18
SLIDE 18

1 . 1 8

S Q L

 S

Q L : w i d e l y u s e d ( d e c l a r a t i v e ) n

  • n
  • p

r

  • c

e d u r a l l a n g u a g e

 E . g . fj n d t h e n a m e

  • f

t h e c u s t

  • m

e r w i t h c u s t

  • m

e r

  • i

d 1 9 2

  • 8

3

  • 7

4 6 5 s e l e c t c u s t

  • m

e r . c u s t

  • m

e r

  • n

a m e f r

  • m

c u s t

  • m

e r w h e r e c u s t

  • m

e r . c u s t

  • m

e r

  • i

d = ‘ 1 9 2

  • 8

3

  • 7

4 6 5 ’  E . g . fj n d t h e b a l a n c e s

  • f

a l l a c c

  • u

n t s h e l d b y t h e c u s t

  • m

e r w i t h c u s t

  • m

e r

  • i

d 1 9 2

  • 8

3

  • 7

4 6 5 s e l e c t a c c

  • u

n t . b a l a n c e f r

  • m

d e p

  • s

i t

  • r

, a c c

  • u

n t w h e r e d e p

  • s

i t

  • r

. c u s t

  • m

e r

  • i

d = ‘ 1 9 2

  • 8

3

  • 7

4 6 5 ’ a n d d e p

  • s

i t

  • r

. a c c

  • u

n t

  • n

u m b e r = a c c

  • u

n t . a c c

  • u

n t

  • n

u m b e r

slide-19
SLIDE 19

1 . 1 9

D a t a I n t e g r i t y

T r a n s a c t i

  • n

p r

  • c

e s s i n g

 Wh

y m u s t w e m a n a g e c

  • n

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

  • d

a t a ? J

  • h

n a n d J a n e w i t h d r a w $ 5 a n d $ 1 f r

  • m

a c

  • m

m

  • n

a c c

  • u

n t … I n i t i a l b a l a n c e i s $ 3 . F i n a l b a l a n c e … I t d e p e n d s …

J

  • h

n : 1 . g e t B a l a n c e ( ) 2 . b a l a n c e = b a l a n c e

  • $

5 3 . u p d a t e B a l a n c e ( ) J a n e : 1 . g e t B a l a n c e ( ) 2 . b a l a n c e = b a l a n c e

  • $

1 3 . u p d a t e B a l a n c e ( ) $ 3 $ 3 $ 2 5

slide-20
SLIDE 20

1 . 2

D a t a I n t e g r i t y

R e c

  • v

e r y

T r a n s f e r $ 5 f r

  • m

a c c

  • u

n t A ( $ 1 ) t

  • a

c c

  • u

n t B ( $ 2 )

1 . A . g e t B a l a n c e ( ) 2 . I f ( b a l a n c e

A

> $ 5 ) 3 . b a l a n c e

A

= b a l a n c e

A

– 5 4 . A . u p d a t e B a l a n c e ( b a l a n c e

A

) 5 . B . g e t B a l a n c e ( ) 6 . b a l a n c e

B

= b a l a n c e

B

+ 5 7 . B . u p d a t e B a l a n c e ( b a l a n c e

B

) S y s t e m c r a s h e s ….

R e c

  • v

e r y m a n a g e m e n t

slide-21
SLIDE 21

1 . 2 1

D a t a b a s e A d mi n i s t r a t

  • r

( D B A )

 D

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

  • B

a l a n c e n e e d s

  • f

m u l t i p l e a p p l i c a t i

  • n

s  D

a t a b a s e t u n i n g

  • M

a k e a p p l i c a t i

  • n

s r u n f a s t e r

  • P

i c k p h y s i c a l s t r u c t u r e s  M

a n a g e r e l i a b i l i t y , c

  • r

r e c t n e s s , s e c u r i t y , …

slide-22
SLIDE 22

1 . 2 2

A l t e r n a t i v e A p p r

  • a

c h e s

 N

  • S

Q L ( e . g . , M

  • n

g

  • D

B , C a s s a n d r a , C

  • u

c h B a s e )

 H

a d

  • p

 E

t c .

 T

h e y g i v e u p s

  • m

e

  • f

t h e t h i n g s t h a t w e j u s t d i s c u s s e d i n

  • r

d e r t

  •  s

c a l e b e t t e r  b e e a s i e r t

  • d

e p l

  • y

 O

P I N I O N : M i s g u i d e d a t t i t u d e t h a t i t ’ s

  • n

l y c

  • d

e

  • >

t h u s I ’ l l d

  • i

t m y s e l f .

slide-23
SLIDE 23

1 . 2 3

T h e H a r d w a r e M a t t e r s

 L

e g a c y

  • f

d i s k

  • b

a s e d p r

  • c

e s s i n g

 T h e d i s k i s a l w a y s t h e b

  • t

t l e n e c k  M i n i m i z e d i s k a c c e s s e s  T

h e s e d a y s m a i n m e m

  • r

y i s g e t t i n g c h e a p a n d p l e n t i f u l .

 S t

  • r

e a l l d a t a i n m a i n m e m

  • r

y .  S t i l l n e e d s

  • m

e w a y t

  • p

e r s i s t d a t a ( e . g . , d i s k , N V M )  F

  • r

d i s t r i b u t e d D B M S ’ s , t h e n e t w

  • r

k i s t h e b

  • t

t l e n e c k

 M i n i m i z e m e s s a g e p a s s i n g a n d d a t a c

  • p

y i n g .  V

e r y f a s t n e t w

  • r

k s a r e s t a r t i n g t

  • b

e a fg

  • r

d a b l e .

slide-24
SLIDE 24

1 . 2 4

A s s u mp t i

  • n

M y D B

slide-25
SLIDE 25

1 . 2 5

T h e Wo r k l

  • a

d M a t t e r s

 Wo

r k l

  • a

d = t h e q u e r i e s t h a t a r e p r e s e n t e d t

  • t

h e s y s t e m .

 A

p p l i c a t i

  • n

s h a v e d i fg e r e n t c h a r a c t e r i s t i c s t h a t e fg e c t t h e w

  • r

k l

  • a

d .

 O

n e

  • S

i z e d

  • e

s n

  • t

fj t a l l .

 O L T P  O L A P  S c i e n c e

slide-26
SLIDE 26

1 . 2 6

R e a l i t y

O L T P O L A P E T L

O p e r a t i

  • n

a l A n a l y t i c s

slide-27
SLIDE 27

1 . 2 7

A C l

  • s

e r L

  • k

E X T R A C T

I N T E G R A T I O N C L E A N I N G

L O A D

. . .

T r a n s f

  • r

m

slide-28
SLIDE 28

1 . 2 8

O u t l i n e

 1

s t

h a l f

  • f

t h e c

  • u

r s e : a p p l i c a t i

  • n
  • r

i e n t e d

 H

  • w

t

  • d

e v e l

  • p

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

  • n

s : U s e r + D B A

 2

n d

p a r t

  • f

t h e c

  • u

r s e : s y s t e m

  • r

i e n t e d

 L e a r n t h e i n t e r n a l s

  • f

a r e l a t i

  • n

a l D B M S ( d e v e l

  • p

e r f

  • r

O r a c l e . . )