What is a Database Management System (1)

Embed Size (px)

Citation preview

  • 8/9/2019 What is a Database Management System (1)

    1/23

    W h a t i s a D a t a b a s e M a n a g e m e n t S y s t e m ?

    1 . M a n a g e s v e r y l a r g e a m o u n t s o f d a t a .

    2 . S u p p o r t s e c i e n t a c c e s s t o v e r y l a r g e a m o u n t s

    o f d a t a .

    3 . S u p p o r t s c o n c u r r e n t a c c e s s t o v . l . a . d .

    4 . S u p p o r t s s e c u r e , a t o m i c a c c e s s t o v . l . a . d .

    1

  • 8/9/2019 What is a Database Management System (1)

    2/23

    R e l a t i o n a l M o d e l

    B a s e d o n t a b l e s , a s :

    a c c t n a m e b a l a n c e

    1 2 3 4 5 S a l l y 1 0 0 0 . 2 1

    3 4 5 6 7 S u e 2 8 5 . 4 8

    T o d a y u s e d i n m o s t D B M S ' s .

    2

  • 8/9/2019 What is a Database Management System (1)

    3/23

    T h r e e A s p e c t s t o S t u d y i n g D B M S ' s

    1 . M o d e l i n g a n d d e s i g n o f d a t a b a s e s .

    3 A l l o w s e x p l o r a t i o n o f i s s u e s b e f o r e

    c o m m i t t i n g t o a n i m p l e m e n t a t i o n .

    2 . P r o g r a m m i n g : q u e r i e s a n d D B o p e r a t i o n s l i k e

    u p d a t e .

    3 S Q L = i n t e r g a l a c t i c d a t a s p e a k . "

    3 . D B M S i m p l e m e n t a t i o n .

    C S 1 4 5 = 1 + 2 , w h i l e 3 i s c o v e r e d i n C S 2 4 5 ,

    C S 3 4 6 , C S 3 4 7 .

    3

  • 8/9/2019 What is a Database Management System (1)

    4/23

    E n t i t y R e l a t i o n s h i p M o d e l

    D i a g r a m s t o r e p r e s e n t d e s i g n s .

    E n t i t y l i k e o b j e c t , = t h i n g . "

    E n t i t y s e t l i k e c l a s s = s e t o f s i m i l a r "

    e n t i t i e s o b j e c t s .

    A t t r i b u t e = p r o p e r t y o f e n t i t i e s i n a n e n t i t y

    s e t , s i m i l a r t o e l d s o f a s t r u c t .

    I n d i a g r a m s , e n t i t y s e t ! r e c t a n g l e ; a t t r i b u t e

    ! o v a l .

    S t u d e n t s

    I D n a m e

    p h o n e

    h e i g h t

    4

  • 8/9/2019 What is a Database Management System (1)

    5/23

    R e l a t i o n s h i p s

    C o n n e c t t w o o r m o r e e n t i t y s e t s .

    R e p r e s e n t e d b y d i a m o n d s .

    S t u d e n t s C o u r s e s T a k i n g

    R e l a t i o n s h i p S e t

    T h i n k o f t h e v a l u e " o f a r e l a t i o n s h i p s e t a s a

    t a b l e .

    O n e c o l u m n f o r e a c h o f t h e c o n n e c t e d e n t i t y

    s e t s .

    O n e r o w f o r e a c h l i s t o f e n t i t i e s , o n e f r o m e a c h

    s e t , t h a t a r e c o n n e c t e d b y t h e r e l a t i o n s h i p .

    S t u d e n t s C o u r s e s

    S a l l y C S 1 4 5

    S a l l y C S 2 4 4

    J o e C S 1 4 5

    5

  • 8/9/2019 What is a Database Management System (1)

    6/23

    M u l t i w a y R e l a t i o n s h i p s

    U s u a l l y b i n a r y r e l a t i o n s h i p s c o n n e c t i n g t w o E . S .

    s u c e .

    H o w e v e r , t h e r e a r e s o m e c a s e s w h e r e t h r e e

    o r m o r e E . S . m u s t b e c o n n e c t e d b y o n e

    r e l a t i o n s h i p .

    E x a m p l e : r e l a t i o n s h i p a m o n g s t u d e n t s ,

    c o u r s e s , T A ' s . P o s s i b l y , t h i s E R d i a g r a m i s

    O K :

    S t u d e n t s C o u r s e s T a k i n g

    A s s i s t i n g

    T A s

    6

  • 8/9/2019 What is a Database Management System (1)

    7/23

    W o r k s i n C S 1 4 5 , b e c a u s e e a c h T A i s a T A o f

    a l l s t u d e n t s . C o n n e c t i o n s t u d e n t - T A i s o n l y

    v i a t h e c o u r s e .

    B u t w h a t i f s t u d e n t s w e r e d i v i d e d i n t o

    s e c t i o n s , e a c h h e a d e d b y a T A ?

    3 T h e n , a s t u d e n t i n C S 1 4 5 w o u l d b e

    r e l a t e d t o o n l y o n e o f t h e T A ' s f o r C S 1 4 5 .

    W h i c h o n e ?

    N e e d a 3 - w a y r e l a t i o n s h i p t o t e l l .

    7

  • 8/9/2019 What is a Database Management System (1)

    8/23

    S t u d e n t s C o u r s e s

    T A s

    E n r o l l s

    S t u d e n t s C o u r s e s T A s

    A n n C S 1 4 5 D o n

    B o b C S 1 4 5 E d y

    C a l C S 1 4 5 D o n

    8

  • 8/9/2019 What is a Database Management System (1)

    9/23

    B e e r s - B a r s - D r i n k e r s E x a m p l e

    O u r r u n n i n g e x a m p l e f o r t h e c o u r s e .

    F r e q u e n t s S e r v e s

    L i k e s

    B a r s

    B e e r s D r i n k e r s

    n a m e a d d r l i c e n s e

    n a m e n a m e a d d rm a n f

    9

  • 8/9/2019 What is a Database Management System (1)

    10/23

    M u l t i p l i c i t y o f R e l a t i o n s h i p s

    M a n y - m a n y M a n y - o n e O n e - o n e

    R e p r e s e n t a t i o n o f M a n y - O n e

    E R : a r r o w p o i n t i n g t o o n e . "

    3 R o u n d e d a r r o w = e x a c t l y o n e . "

    1 0

  • 8/9/2019 What is a Database Management System (1)

    11/23

    E x a m p l e : D r i n k e r s H a v e F a v o r i t e B e e r s

    F r e q u e n t s S e r v e s

    L i k e s

    B a r s

    B e e r s D r i n k e r s

    n a m e a d d r l i c e n s e

    n a m e n a m e a d d rm a n f

    F a v o r i t e

    1 1

  • 8/9/2019 What is a Database Management System (1)

    12/23

    O n e - O n e R e l a t i o n s h i p s

    P u t a r r o w s i n b o t h d i r e c t i o n s .

    B e e r s

    s e l l e r

    B e s t -

    M a n f s

    D e s i g n I s s u e :

    I s t h e r o u n d e d a r r o w j u s t i e d ?

    D e s i g n I s s u e :

    H e r e , m a n u f a c t u r e r i s a n E . S . ; i n e a r l i e r d i a g r a m s

    i t i s a n a t t r i b u t e . W h i c h i s r i g h t ?

    1 2

  • 8/9/2019 What is a Database Management System (1)

    13/23

    A t t r i b u t e s o n R e l a t i o n s h i p s

    B e e r s

    p r i c e

    B a r s S e l l s

    S h o r t h a n d f o r 3 - w a y r e l a t i o n s h i p :

    B e e r s B a r s S e l l s

    p r i c e

    P r i c e s

    1 3

  • 8/9/2019 What is a Database Management System (1)

    14/23

    A t r u e 3 - w a y r e l a t i o n s h i p .

    3 P r i c e d e p e n d s j o i n t l y o n b e e r a n d b a r .

    N o t i c e a r r o w c o n v e n t i o n f o r m u l t i w a y

    r e l a t i o n s h i p s : a l l o t h e r E . S . d e t e r m i n e o n e

    o f t h e s e . "

    3 N o t s u c i e n t l y g e n e r a l t o e x p r e s s a n y

    p o s s i b i l i t y .

    3 H o w e v e r , i f p r i c e , s a y , d e p e n d e d o n l y o n

    t h e b e e r , t h e n w e c o u l d u s e t w o 2 - w a y

    r e l a t i o n s h i p s : p r i c e - b e e r a n d b e e r - b a r .

    3 O r b e t t e r : j u s t m a k e p r i c e a n a t t r i b u t e o f

    b e e r .

    1 4

  • 8/9/2019 What is a Database Management System (1)

    15/23

    C o n v e r t i n g M u l t i w a y t o 2 - W a y

    B a r o q u e i n E R , b u t n e c e s s a r y i n c e r t a i n

    o b j e c t - o r i e n t e d " m o d e l s .

    C r e a t e a n e w c o n n e c t i n g E . S . t o r e p r e s e n t

    r o w s o f a r e l a t i o n s h i p s e t .

    3 E . g . , J o e ' s B a r , B u d , $ 2 . 5 0 f o r t h e S e l l s

    r e l a t i o n s h i p .

    M a n y - o n e r e l a t i o n s h i p s f r o m t h e c o n n e c t i n g

    E . S . t o t h e o t h e r s .

    B e e r s B a r s

    T h e -

    B e e r

    P r i c e s

    B a r

    T h e - T h e -

    P r i c e

    B B P

    1 5

  • 8/9/2019 What is a Database Management System (1)

    16/23

    R o l e s

    S o m e t i m e s a n E . S . p a r t i c i p a t e s m o r e t h a n o n c e i n

    a r e l a t i o n s h i p .

    L a b e l e d g e s w i t h r o l e s t o d i s t i n g u i s h .

    M a r r i e d

    D r i n k e r s

    w i f e h u s b a n d

    H u s b a n d W i f e

    d

    1

    d

    2

    d

    3

    d

    4

    1 6

  • 8/9/2019 What is a Database Management System (1)

    17/23

  • 8/9/2019 What is a Database Management System (1)

    18/23

    S u b c l a s s e s

    S u b c l a s s = s p e c i a l c a s e = f e w e r e n t i t i e s = m o r e

    p r o p e r t i e s .

    E x a m p l e

    A l e s a r e a k i n d o f b e e r . I n a d d i t i o n t o t h e

    p r o p e r t i e s = a t t r i b u t e s a n d r e l a t i o n s h i p s o f b e e r s ,

    t h e r e i s a c o l o r " a t t r i b u t e f o r a l e s .

    1 8

  • 8/9/2019 What is a Database Management System (1)

    19/23

  • 8/9/2019 What is a Database Management System (1)

    20/23

    D i e r e n t S u b c l a s s V i e w p o i n t s

    1 . E R v i e w p o i n t : A n e n t i t y h a s a c o m p o n e n t i n

    e a c h e n t i t y s e t t o w h i c h i t l o g i c a l l y b e l o n g s .

    3I t s p r o p e r t i e s a r e t h e u n i o n o f t h e

    p r o p e r t i e s o f t h e s e E . S .

    2 . C o n t r a s t s w i t h o b j e c t - o r i e n t e d v i e w p o i n t : A n

    o b j e c t e n t i t y b e l o n g s t o e x a c t l y o n e c l a s s .

    3 I t i n h e r i t s p r o p e r t i e s o f i t s s u p e r c l a s s e s .

    i s a

    B e e r s

    A l e s

    n a m e m a n f

    c o l o r

    P e t e ' s A l e

    2 0

  • 8/9/2019 What is a Database Management System (1)

    21/23

  • 8/9/2019 What is a Database Management System (1)

    22/23

    E x a m p l e

    S u p p o s e n a m e i s k e y f o r B e e r s .

    i s a

    B e e r s

    A l e s

    m a n f

    c o l o r

    n a m e

    B e e r n a m e i s a l s o k e y f o r a l e s .

    3 I n g e n e r a l , k e y a t r o o t i s k e y f o r a l l .

    2 2

  • 8/9/2019 What is a Database Management System (1)

    23/23

    E x a m p l e : A M u l t i a t t r i b u t e K e y

    C o u r s e s

    d e p t n u m b e r h o u r s

    r o o m

    P o s s i b l y , h o u r s + r o o m a l s o f o r m s a k e y , b u t

    w e h a v e n o t d e s i g n a t e d i t a s s u c h .