Mr.Warawut Khangkhan
Facebook:
Facebook: http://www.facebook.com/AjWarawut
Twitter: http://twitter.com/awarawut
E-Mail: awarawut@hotmail.com
Mobile: 089-461-9591
         089-461-



                    5ก ก           F
                    (Database Design)
กF ก F                         F                       F       ก           F
     กF
  ก ก                                F                       F
       ก               ก                     F
           F            F
                             F           F         F F ก             F   ก
       ก                                         F FF ก
Mr.Warawut Khangkhan        Chapter 05 Database Design                           2
F         ก                         ก F
               (Entity)
                   F (Attribute)
                      F (Relationships)




Mr.Warawut Khangkhan      Chapter 05 Database Design   3
(Entity)
                    F                                          F
               F        F F ก F                           F   ก ก
  ก                         F   ก                   F ก          ก
           F             ก    F                     กF                F ก
           F
           ก F                                                      F
       (Customers)                   (Orders)                 (Products)
Mr.Warawut Khangkhan        Chapter 05 Database Design                     4
F (Attribute)
            F              ก
                 กF                    F                    F
     ก F (Customers)
             กF
            กF
           FกF                                         F(   )
                 F
                    F
Mr.Warawut Khangkhan      Chapter 05 Database Design            5
F (Attribute)
                       (Orders)                                      F (Products)
                                                                                F
                                    F                                         F
                       F            F                                    F F
                       กF                                                 F           F
                            F                                               F
                                F                                                   F
                   F                                                              F
Mr.Warawut Khangkhan                    Chapter 05 Database Design                        6
F (Relationships)
                           ก F (Customers)                   (Orders)
                       F           กF       1 N
            F                     กF                                      F
                 F               FกF                         F            F
                                       F                     กF
                                          F                       F
                                                                      F
                                                         F
Mr.Warawut Khangkhan        Chapter 05 Database Design                        7
F                                F (Relational Database)
       ก
                                 ก F (Customers)                  (Orders)
                       F                 กF
                                                  1 N
                                        กF                                     F
                           F           FกF                        F            F
           F ก             F F               F                    กF
                                                F                      F
   F ก
                                                                           F
                                                              F
Mr.Warawut Khangkhan             Chapter 05 Database Design                    8
F      F               F
         F (Field) /                   F (Attribute)
        F F              ก                กก F              ก
            F (Record) /               (Tuple)
             ก         F                    F      ก
             (Table) /               (Relation)
             ก            F                     F       ก

Mr.Warawut Khangkhan       Chapter 05 Database Design           9
F     F                F
               Field
  ก F     F ก F                 F กF
003     P&S STORE               1                               F 159   21 (   ก)   ก .
015     Happy Shop                            29 .             F F             ก
                                                                        Record
181     The Book Shop        Asia Hotel 296 .              ก
213     P'S Line             2675    F9         F    .95                ก ก .
008     The Bookseller       428 Rama I Road, Siam Square Bangkok.




Mr.Warawut Khangkhan          Chapter 05 Database Design                            10
F (Relationships)
              F     F
  (One-to-One Relationships)
                F        FกF
  (One-to-Many Relationships)
                  F กF FกF
  (Many-to-Many Relationships)

Mr.Warawut Khangkhan   Chapter 05 Database Design         11
One-to-
One-to-One Relationships (1:1)
                       F                        F       F                          ก
       F 1     F                                                              Fก
     ก    F 1    F  ก                                             F       F
            ก 1 F F                                                   F
             F                                      F       1:1



Mr.Warawut Khangkhan       Chapter 05 Database Design                              12
F
                         F        F            F                                                                                 F   F (    )

1:1               0005
                  0100
                                      F
                                           F
                                                               F                         90                                            219.63
                                                                                                                                       219.63
                                                                                                                                                 Yes
                                                                                                                                                 Yes
                  0125           SALES MANAGER FACTOMATIC                                                                              700.93    No
                  0051           SECRETS OF STARGATE                                                                                  1,842.99   No
                  0010           US ATLAS                                                                                              540.19    No
                  0007           VIDEO CONFERENCING CARD-FLY VIDEO OF SOUND                                                            369.16    Yes
                  0008                    กF       F                        Panasonic Model VHS F NV-VX3                               260.00    Yes
                  0023           JAPANESE 1, LIYC                                                                                      278.00    No
                  0055           JAPANESE 2, LIYC                                                                                      278.00    No
                   1
                                                                                 F
                                                           F       F                 F
                                          0005                         F                      F      90                                                400
                                          0100                               F                                                                         155
                                          0125                     SALES MANAGER FACTOMATIC                                                            169
                                          0051                     SECRETS OF STARGATE                                                                 197
                                          0010                     US ATLAS                                                                            159
                                          0007                     VIDEO CONFERENCING CARD-FLY VIDEO OF SOUND                                          205
                                          0008                             กF             F       Panasonic Model VHS F NV-VX3                         177

Mr.Warawut Khangkhan                      0023 Chapter 05 Database Design
                                                JAPANESE 1, LIYC                                                                                       326   13
                             1                                                                                                                         159
                                          0055 JAPANESE 2, LIYC
One-to-
One-to-One Relationships (1:1)
                           F        1:1
       F
                               F       F                        F            ก
                               ก               F   F ก              F
           F F                 ก           F
                       ก                             F

Mr.Warawut Khangkhan               Chapter 05 Database Design           14
One-To-
One-To-Many Relationships (1:N)
                          (1
                           F                       F
            F
                       F                                             F                F 1
                F                                           Fก                              F 2
                F       กก F               ก                                 F       กF
                        F F                                              F       F                F
                       กF                                        F
Mr.Warawut Khangkhan           Chapter 05 Database Design                                    15
กF

1:N     กF
      003
                 F กF
                P&S STORE
                                                F ก F
                                                1                                 F 159     21 (       ก)   ก .
  1   015       Happy Shop                                29 .                   F F                   ก
      181       The Book Shop              Asia Hotel 296 .                  ก
      213       P'S Line                   2675     F9             F   .95                  ก ก .
      008       The Bookseller             428 Rama I Road, Siam Square Bangkok.

                                 F          N

                    ก        F         กF                      F             F         F           F             F   F   F       (%)
                    10258            015            21/10/xx            28/10/xx           0005             8                25.00%
                                                                                           0100             8                0.00%
            N
                                                                                           0125             15               0.00%
                    10265            181            21/10/xx            27/10/xx           0005             31               0.00%
                                                                                           0010             15               0.00%
                    10278            015            24/10/xx            3/11/xx            0007             16               0.00%
                                                                                           0008             31               25.00%
                                                                                           0023             4                0.00%
Many-to-
Many-to-Many Relationships (M:N)
                           F                   F                     F    FF
               ก                       F                        F       F
       F               F                               F       Many-to-One ก
         2                                                 F   Many-to-Many
  Relationships



Mr.Warawut Khangkhan           Chapter 05 Database Design                  17
Many-to-
Many-to-Many Relationships (M:N)
            F                        F       กF
      F                    F กF 1 F
  ก ก                  F                        F               F
   F ก                     F   F                           Fก       F
                  Many-to-Many



Mr.Warawut Khangkhan          Chapter 05 Database Design                18
ก                 F
                                                                                                 N
                                                                                                     ก           F                 F              F   F   F         (%)
M:N                                                                                          N
                                                                                                     10258             0005                  8                25.00%
                                   F                                                                 10258             0100        N         8                0.00%
                                                                                             N
      ก               F                             ก F                   F      F       F           10258             0125                  15               0.00%
  1   10258                                     015            21/10/xx       28/10/xx               10265             0005                  31               0.00%
      10265                                     181            21/10/xx       27/10/xx               10265             0010N                 15               0.00%
      10278                                     015            24/10/xx       3/11/xx                10278             0007                  16               0.00%
                                                                                                     10278             0008                  31               25.00%
                                                                                                     10278             0023                  4                0.00%

                  F
              F            F                    F                                                            F       F (       )
  1   0005                     F                          F      90                                                    219.63          Yes                    400
      0100                                  F                                                                          219.63          Yes                    155
      0125                SALES MANAGER FACTOMATIC                                                                     700.93          No                     169
      0051                SECRETS OF STARGATE                                                                         1,842.99         No                     197
      0010                US ATLAS                                                                                     540.19          No                     159
      0007                VIDEO CONFERENCING CARD-FLY VIDEO OF SOUND                                                   369.16          Yes                    205
      0008                             กF           F         Panasonic Model VHS F NV-VX3                             260.00          Yes                    177
      0023                JAPANESE 1, LIYC                            Chapter 05 Database Design                       278.00          No                     326
      0055                JAPANESE 2, LIYC                                                                             278.00          No                     159
F                F               F
  Primary Key: PK ( F ก)
  Candidate Key ( F F F )
  Composite Key
  Foreign Key: FK



Mr.Warawut Khangkhan       Chapter 05 Database Design       20
Primary Key: PK
                       F   F    F ก                      F     F
                               F F                 Primary Key
                                   F




Mr.Warawut Khangkhan           Chapter 05 Database Design          21
Candidate Key
                 F                             F                  ก      F
                          Primary Key                     F Fก          F ก
      F                           F ก F                           ก F
      F ก              F F F       F ก                     FF F




Mr.Warawut Khangkhan         Chapter 05 Database Design                      22
Composite Key
                       F F F F                              F       F
         F     ก      Primary Key                       F       F       ก
        ก F Composite Key




Mr.Warawut Khangkhan       Chapter 05 Database Design                       23
Foreign Key
                 F                      ( Many)
             Fก   F                     Primary Key   ก
      ( One)                              2               F
  One-to-Many F ก




Mr.Warawut Khangkhan   Chapter 05 Database Design             24
ก           F
                                                                    ก       F             F          F   F   F        (%)
                                                          N         10258          0005         8                25.00%
                 1
             F                                                      10258          0100         8                0.00%
 ก       F             กF              F      F       F             10258          0125         15               0.00%
 10258               015    21/10/xx       28/10/xx                 10265          0005         31               0.00%
 10265               181    21/10/xx       27/10/xx                 10265          0010         15               0.00%
 10278               015    24/10/xx       3/11/xx                  10278          0007         16               0.00%
                                                                    10278          0008         31               25.00%
Primary Key
                                                                    10278          0023         4                0.00%

                                                          Foreign Key           Composite Key




     Mr.Warawut Khangkhan                         Chapter 05 Database Design                                     25
ก             ก                                F
                  ก ก F                             F
    (Application Database)
       F ก
         F




Mr.Warawut Khangkhan   Chapter 05 Database Design       26
F ก                   ก              F
                           F       F                    F
                                             ก ก FF
     F           F                          กF                                  F
         F           ก(        F             ก F ก)
                     ก             ก        ก F F                       F F F
                       F
             F                               F F            ก

Mr.Warawut Khangkhan                   Chapter 05 Database Design                   27
ก          ก                                 F
1.   ก                       ก                                  F
2.   ก                 F ก                                F F
3.   ก                             F          F                         F
4.     ก               F                             F                      F
     ก ก Normalization


Mr.Warawut Khangkhan         Chapter 05 Database Design                         28
Normalization
                           F ก  F                                                 F       F
       ก                F ก กF                                                  Fก
                       F ก Normalization
                         F          F                                   F F F        กF       F

                Fก                          กF                  F
           FF
                Fก                                F     F               ก        F
                             F          F                   F       F
Mr.Warawut Khangkhan             Chapter 05 Database Design                                   29
F F ก Normalization
0NF
                F       F กF         ก (Repeating Group)
1NF
                F       F               F    F F F                ก F       F            F
2NF
                F       F            F                        ก         F       F F PK
3NF                    Candidate Key

                F       F ก        Fก               ก F (Multivalve Dependency)
4NF
Mr.Warawut Khangkhan             Chapter 05 Database Design                       30
ก F 1 (First Normal Form)
         F        F      F         F ก     F
                         F   F ก F 1 F F
  ก          ก         F F ก     ก       F                F




Mr.Warawut Khangkhan         Chapter 05 Database Design       31
ก F 2 (Second Normal Form)
                     F ก F 2 F F                 F F F
                 F   (   ก F Non-key Attribute) ก F
         F               F ก F        ก F ก
             F
                            F              F ก F 2           ก       ก        F
                      ก F                      F กก              F
     F               ก F                        F
Mr.Warawut Khangkhan            Chapter 05 Database Design               32
ก F 3 (Third Normal Form)
                     F ก F          2            F        F                 F
                      ก                      F                F F F ก           F
     F F
                             F                           F ก F      3 F ก
       ก         F      ก               F                  ก                             F
              F ก                                    F       F          F                    F

Mr.Warawut Khangkhan             Chapter 05 Database Design                         33
ก F 4 (Fourth Normal Form)
           F ก F 4 F F ก            Fก
      ก F (Multivalve Dependency)                        F
         Many-to-Many             ก F
             ก          FB     F  FA ก
     Fก              กก F            FC
                F     F ก F 4 F       ก
       F      ก F         F ก F ก F
Mr.Warawut Khangkhan   Chapter 05 Database Design   34
E-R Diagram




Mr.Warawut Khangkhan   Chapter 05 Database Design   35

Database Design

  • 1.
    Mr.Warawut Khangkhan Facebook: Facebook: http://www.facebook.com/AjWarawut Twitter:http://twitter.com/awarawut E-Mail: awarawut@hotmail.com Mobile: 089-461-9591 089-461- 5ก ก F (Database Design)
  • 2.
    กF ก F F F ก F กF ก ก F F ก ก F F F F F F F ก F ก ก F FF ก Mr.Warawut Khangkhan Chapter 05 Database Design 2
  • 3.
    F ก ก F (Entity) F (Attribute) F (Relationships) Mr.Warawut Khangkhan Chapter 05 Database Design 3
  • 4.
    (Entity) F F F F F ก F F ก ก ก F ก F ก ก F ก F กF F ก F ก F F (Customers) (Orders) (Products) Mr.Warawut Khangkhan Chapter 05 Database Design 4
  • 5.
    F (Attribute) F ก กF F F ก F (Customers) กF กF FกF F( ) F F Mr.Warawut Khangkhan Chapter 05 Database Design 5
  • 6.
    F (Attribute) (Orders) F (Products) F F F F F F F กF F F F F F F F F Mr.Warawut Khangkhan Chapter 05 Database Design 6
  • 7.
    F (Relationships) ก F (Customers) (Orders) F กF 1 N F กF F F FกF F F F กF F F F F Mr.Warawut Khangkhan Chapter 05 Database Design 7
  • 8.
    F F (Relational Database) ก ก F (Customers) (Orders) F กF 1 N กF F F FกF F F F ก F F F กF F F F ก F F Mr.Warawut Khangkhan Chapter 05 Database Design 8
  • 9.
    F F F F (Field) / F (Attribute) F F ก กก F ก F (Record) / (Tuple) ก F F ก (Table) / (Relation) ก F F ก Mr.Warawut Khangkhan Chapter 05 Database Design 9
  • 10.
    F F F Field ก F F ก F F กF 003 P&S STORE 1 F 159 21 ( ก) ก . 015 Happy Shop 29 . F F ก Record 181 The Book Shop Asia Hotel 296 . ก 213 P'S Line 2675 F9 F .95 ก ก . 008 The Bookseller 428 Rama I Road, Siam Square Bangkok. Mr.Warawut Khangkhan Chapter 05 Database Design 10
  • 11.
    F (Relationships) F F (One-to-One Relationships) F FกF (One-to-Many Relationships) F กF FกF (Many-to-Many Relationships) Mr.Warawut Khangkhan Chapter 05 Database Design 11
  • 12.
    One-to- One-to-One Relationships (1:1) F F F ก F 1 F Fก ก F 1 F ก F F ก 1 F F F F F 1:1 Mr.Warawut Khangkhan Chapter 05 Database Design 12
  • 13.
    F F F F F F ( ) 1:1 0005 0100 F F F 90 219.63 219.63 Yes Yes 0125 SALES MANAGER FACTOMATIC 700.93 No 0051 SECRETS OF STARGATE 1,842.99 No 0010 US ATLAS 540.19 No 0007 VIDEO CONFERENCING CARD-FLY VIDEO OF SOUND 369.16 Yes 0008 กF F Panasonic Model VHS F NV-VX3 260.00 Yes 0023 JAPANESE 1, LIYC 278.00 No 0055 JAPANESE 2, LIYC 278.00 No 1 F F F F 0005 F F 90 400 0100 F 155 0125 SALES MANAGER FACTOMATIC 169 0051 SECRETS OF STARGATE 197 0010 US ATLAS 159 0007 VIDEO CONFERENCING CARD-FLY VIDEO OF SOUND 205 0008 กF F Panasonic Model VHS F NV-VX3 177 Mr.Warawut Khangkhan 0023 Chapter 05 Database Design JAPANESE 1, LIYC 326 13 1 159 0055 JAPANESE 2, LIYC
  • 14.
    One-to- One-to-One Relationships (1:1) F 1:1 F F F F ก ก F F ก F F F ก F ก F Mr.Warawut Khangkhan Chapter 05 Database Design 14
  • 15.
    One-To- One-To-Many Relationships (1:N) (1 F F F F F F 1 F Fก F 2 F กก F ก F กF F F F F F กF F Mr.Warawut Khangkhan Chapter 05 Database Design 15
  • 16.
    กF 1:N กF 003 F กF P&S STORE F ก F 1 F 159 21 ( ก) ก . 1 015 Happy Shop 29 . F F ก 181 The Book Shop Asia Hotel 296 . ก 213 P'S Line 2675 F9 F .95 ก ก . 008 The Bookseller 428 Rama I Road, Siam Square Bangkok. F N ก F กF F F F F F F F (%) 10258 015 21/10/xx 28/10/xx 0005 8 25.00% 0100 8 0.00% N 0125 15 0.00% 10265 181 21/10/xx 27/10/xx 0005 31 0.00% 0010 15 0.00% 10278 015 24/10/xx 3/11/xx 0007 16 0.00% 0008 31 25.00% 0023 4 0.00%
  • 17.
    Many-to- Many-to-Many Relationships (M:N) F F F FF ก F F F F F F Many-to-One ก 2 F Many-to-Many Relationships Mr.Warawut Khangkhan Chapter 05 Database Design 17
  • 18.
    Many-to- Many-to-Many Relationships (M:N) F F กF F F กF 1 F ก ก F F F F ก F F Fก F Many-to-Many Mr.Warawut Khangkhan Chapter 05 Database Design 18
  • 19.
    F N ก F F F F F (%) M:N N 10258 0005 8 25.00% F 10258 0100 N 8 0.00% N ก F ก F F F F 10258 0125 15 0.00% 1 10258 015 21/10/xx 28/10/xx 10265 0005 31 0.00% 10265 181 21/10/xx 27/10/xx 10265 0010N 15 0.00% 10278 015 24/10/xx 3/11/xx 10278 0007 16 0.00% 10278 0008 31 25.00% 10278 0023 4 0.00% F F F F F F ( ) 1 0005 F F 90 219.63 Yes 400 0100 F 219.63 Yes 155 0125 SALES MANAGER FACTOMATIC 700.93 No 169 0051 SECRETS OF STARGATE 1,842.99 No 197 0010 US ATLAS 540.19 No 159 0007 VIDEO CONFERENCING CARD-FLY VIDEO OF SOUND 369.16 Yes 205 0008 กF F Panasonic Model VHS F NV-VX3 260.00 Yes 177 0023 JAPANESE 1, LIYC Chapter 05 Database Design 278.00 No 326 0055 JAPANESE 2, LIYC 278.00 No 159
  • 20.
    F F F Primary Key: PK ( F ก) Candidate Key ( F F F ) Composite Key Foreign Key: FK Mr.Warawut Khangkhan Chapter 05 Database Design 20
  • 21.
    Primary Key: PK F F F ก F F F F Primary Key F Mr.Warawut Khangkhan Chapter 05 Database Design 21
  • 22.
    Candidate Key F F ก F Primary Key F Fก F ก F F ก F ก F F ก F F F F ก FF F Mr.Warawut Khangkhan Chapter 05 Database Design 22
  • 23.
    Composite Key F F F F F F F ก Primary Key F F ก ก F Composite Key Mr.Warawut Khangkhan Chapter 05 Database Design 23
  • 24.
    Foreign Key F ( Many) Fก F Primary Key ก ( One) 2 F One-to-Many F ก Mr.Warawut Khangkhan Chapter 05 Database Design 24
  • 25.
    F ก F F F F F (%) N 10258 0005 8 25.00% 1 F 10258 0100 8 0.00% ก F กF F F F 10258 0125 15 0.00% 10258 015 21/10/xx 28/10/xx 10265 0005 31 0.00% 10265 181 21/10/xx 27/10/xx 10265 0010 15 0.00% 10278 015 24/10/xx 3/11/xx 10278 0007 16 0.00% 10278 0008 31 25.00% Primary Key 10278 0023 4 0.00% Foreign Key Composite Key Mr.Warawut Khangkhan Chapter 05 Database Design 25
  • 26.
    ก F ก ก F F (Application Database) F ก F Mr.Warawut Khangkhan Chapter 05 Database Design 26
  • 27.
    F ก ก F F F F ก ก FF F F กF F F ก( F ก F ก) ก ก ก F F F F F F F F F ก Mr.Warawut Khangkhan Chapter 05 Database Design 27
  • 28.
    ก F 1. ก ก F 2. ก F ก F F 3. ก F F F 4. ก F F F ก ก Normalization Mr.Warawut Khangkhan Chapter 05 Database Design 28
  • 29.
    Normalization F ก F F F ก F ก กF Fก F ก Normalization F F F F F กF F Fก กF F FF Fก F F ก F F F F F Mr.Warawut Khangkhan Chapter 05 Database Design 29
  • 30.
    F F กNormalization 0NF F F กF ก (Repeating Group) 1NF F F F F F F ก F F F 2NF F F F ก F F F PK 3NF Candidate Key F F ก Fก ก F (Multivalve Dependency) 4NF Mr.Warawut Khangkhan Chapter 05 Database Design 30
  • 31.
    ก F 1(First Normal Form) F F F F ก F F F ก F 1 F F ก ก F F ก ก F F Mr.Warawut Khangkhan Chapter 05 Database Design 31
  • 32.
    ก F 2(Second Normal Form) F ก F 2 F F F F F F ( ก F Non-key Attribute) ก F F F ก F ก F ก F F F ก F 2 ก ก F ก F F กก F F ก F F Mr.Warawut Khangkhan Chapter 05 Database Design 32
  • 33.
    ก F 3(Third Normal Form) F ก F 2 F F F ก F F F F ก F F F F F ก F 3 F ก ก F ก F ก F F ก F F F F Mr.Warawut Khangkhan Chapter 05 Database Design 33
  • 34.
    ก F 4(Fourth Normal Form) F ก F 4 F F ก Fก ก F (Multivalve Dependency) F Many-to-Many ก F ก FB F FA ก Fก กก F FC F F ก F 4 F ก F ก F F ก F ก F Mr.Warawut Khangkhan Chapter 05 Database Design 34
  • 35.
    E-R Diagram Mr.Warawut Khangkhan Chapter 05 Database Design 35