] > The Entity-Relationship (ER) Model

The Entity-Relationship (ER) Model

2.1 Background

2.2 An Entity-Relationship (ER) Diagram

                                ------                              ----    ----                           ||-WORKS  -FOR----           -|||||||||     |||----      ----           -|Lname||-    ||||||||--||---  ||||||||||||      |||||||||-|       |-|Name-|- ||1   ||Locations||-      |Fname|-|-||||  ||| ||||||------------|||-||||||            |Name||--|||    |DEPARTMENT    |         |||||  |   |||||||||||----||--|||--|||||||||||||||||        -Ssn|-  |  || -|Number-||- || ||||NumOfEmployees||||-         |||--- ||||    ||||||||--------         --------||---|    1-----      -----         -EMPLOYEE------------MANAGING  ----             ||  ||| -----     ----- --||||||||||           || ---- |||    -----    --||StartDate||-- employee |||---  ----||employer----1     ||||||       |||--         --||       --------       --SUPERVISION ----    -----    -----           ----  -----    -----           -----              ----       --DEPENDENTS    -OF ----                           -----        -----                              -----  -----                       -|||||||-  -|N--                       |Name|---   ||           |||||||||||||||| ---------------|          -||Relationship||--|-DEPENDENT----|                  -|        ----------------

2.3 Entity Types

2.4 Relationship Types

                     ------                   |---    ----                  ||-WORKS-FOR--                 ||    -|--               ||  -----------|              ||   -DEPARTMENT-|             ||        ----       -----||---------   -----       -EMPLOYEE--  -MANAGING--        |||---||| --------- employer||--   --|employee-----      |-SUPERVISION--|----    ----         ------  --DEPENDENTS-OF--                    ----  ----                       -|--                   |---------|-                   |DEPENDENT--

2.5 Attributes

                     -----                   |---    ----                  ||WORKS-FOR-- |||||        -|Lname|-||Name|-|-- ||Locations||| |Fname--|||||||| |||||-------||||||||  ||||||--Name-| |||DEPARTMENT--|||||||||||       |Ssn- ||||Number|-----||NumOfEmployees||-       -----||---------   ----       -EMPLOYEE--  --MANAGING|-         ------        --||StartDate||      ----    ----    -----      -SUPERVISION-- ----    ----         ------  --DEPENDENTS-OF--                   -----  ----                |Name- ----       |||||||||||-----------|       ||Relationship||--DEPENDENT--

2.6 Keys and Weak Entity Types

                               ------    |||||||||| ||||||||||    -----  -----    |Fname|-|-|||Lname||- -----         ----  |||||   |Name||--   ----DEPENDENTS    -OF --- -|Ssn---   |||||||-----  -----          -----  |||---   || -----         -----    -----   -------|----|      ||||||||  ---|--   -EMPLOYEE----      |Name----    |            ||||||||||||||||--------------|         -||Relationship ||--|DEPENDENT     |           ||||||||||||||  ----------------

Regular entity types with keys are sometimes called strong entity types.

2.7 Structural Relationship Constraints

Participation constraint
                      -----                    -----  ----      -----------|     -EMPLOYEE-------DEPENDENTS-OF-------DEPENDENT||     ----------    -----    -----    ------------                      --------                         -       --||-           --|||          -----||-      -- ∙---------------|----------------∙∙  -      -  ∙---------------|----------------∙  |      -- ∙---------------|----------------∙  -       -|∙---          -|||-     ---------∙|--         ||                               || partial participation                total participation

Cardinality ratio constraint

                   ----                -----  -----     -----------| -EMPLOYEE----1--DEPENDENTS-OF--N---|-DEPENDENT-| ----------    -----    -----    ------------                  --------                     --   --|||-           -|||          -----||-   - ∙---------------|----------------∙∙  -  -- ∙---------------|----------------∙  |   - ∙---------------|----------------∙  -   -|∙|--          -|||-      --------∙|--     ||         one-to- many            ||                 relationship

Cardinality constraint
Specifies lower and upper bounds on the number of relationships each entity can participate in.
                           -----                        |----   ----                       ||-WORKS-FOR--                      ||    --|--                     || |-----|(1,N)|                (1,N)||  | DEPARTMENT|                  ||     -----|(1,1)-                 ||         --|--           -----||--(0,N)----   ----           -EMPLOYEE---   -MANAGING--            |||--||| ------  --- supervisor ||------|||    ---(0,N )   (0,N)  |SUPERVISION-|(0,1)---------           ----- ----  -----     -----               --     ---DEPENDENTS-OF---                         ----- -----                             -|-                        ------|(1,1)-|                        |-DEPENDENT-||                        ------------

Summary of Notation

Entity
|-------|  --------
Weak Entity
---------| |-------|| ----------
Relationship
    ----  ----  ---- ---      ---   --------
Identifying Relationship
    ------  ----    ---- -----    -----    --------
Attribute
    -||||||||||| ----|||||-||||||
Key Attribute
    ||||||||||| ----||||----|||-        ||-|||
Multivalued Attribute
     |||||||||||| -----|||||||||||--       ||||||||||
Composite Attribute
 |||||||||||    ||||||||||| -||||||||--|   -|--|||||||-|     ----||--||||--||         |||||-|||||-
Derived Attribute
-----||||||||||-     ||||||||||||
Total participation of E2 in R
-------------------| E1--   --R--- ---E2-
Cardinality ratio 1 : N for E1 : E2 in R
------1-----N------| E1--   --R---   -E2-
Structural constraint (min,max) on participation of E in R
-----------min,max-|         -R----   E--
[Problem 3.16]

2.8 Assignment #1

Due: We, Jan 21

Problem 3.21 in textbook (pages 79–80 4th ed; 93 5th ed):

“Design an er schema for keeping track of information about votes taken in the U.S. House of Representatives during the current two-year congressional session. The database needs to keep track of each U.S. state’s Name (e.g., Texas, New York, California) and includes the Region of the state (whose domain is {Northeast, Midwest, Southeast, Southwest, West}). Each congressperson in the House of Representatives is described by their Name, and includes the District represented, the StartDate when they were first elected, and the political Party they belong to (whose domain is {Republican, Democrat, Independent, Other}). The database keeps track of each bill (i.e., proposed law), and includes the BillName, the DateOfVote on the bill, whether the bill PassedOrFailed (whose domain is {YES,NO}), and the Sponsor (the congressperson(s) who sponsored—i.e., proposed—the bill). The database keeps track how each congressperson voted on each bill (domain of vote attribute is {Yes, No, Abstain, Absent}). Draw an er schema diagram for the above application. State clearly any assumptions you make.”

Notes

Reference: Ch. 3 in textbook.