25SpER Model YenChuPan

download 25SpER Model YenChuPan

of 17

Transcript of 25SpER Model YenChuPan

  • 8/8/2019 25SpER Model YenChuPan

    1/17

    Entity-Relationship Data

    Model

    CS 157A

    Professor Sin-Min Lee

    Student: Yen-Chu Pan

  • 8/8/2019 25SpER Model YenChuPan

    2/17

    Elements of E-R Model In the E/R model, the structure of data is

    represented graphically, as an entity-

    relationship diagram, using three Principalelement types: Entity Sets.

    An entity is an abstract object of some sort, and acollection of similar entities forms an entity set.

    Attributes The properties of the entities in the set.

    Relationship The connections among two or more entity Sets

  • 8/8/2019 25SpER Model YenChuPan

    3/17

    Example of Elements of E-R

    Model Entity Sets Departments

    Professors

    Students Administrators

    Attributes Name of Departments, Phone No., Address...

    Name, SSN, Address of Professors...

    Relationship Students and Professors are under a certain

    department

    Admin manage the campus/ departments

  • 8/8/2019 25SpER Model YenChuPan

    4/17

    Example of the 3 elements in

    E/R Diagram

  • 8/8/2019 25SpER Model YenChuPan

    5/17

    Classification of Constraints

    1. Keys

    2. Single-value constraints

    3. Multi-valued constraints

    4. Mapping Cardinalities and

    Participation Constraints

  • 8/8/2019 25SpER Model YenChuPan

    6/17

    Key in the E/R Model

    Superkeyis a set of one or more attributes that, takencollectively, for us to identify uniquely an item in the entity set.For example, customer-id is a superkey.

    Candidate keyis a minimal superkey. For example, customer-name and customer-street is sufficient to distinguish amongmembers of the customer entity set. Then {customer-name,customer-street } is a candidate key.

    Primary keydenotes a candidate key that is chosen by the

    database designer as the principal means of identifying itemswithin an entity set. the primary key should be chosen suchthat its attributes are never, or very rarely, changed. Forexample, Social-security numbers are guaranteed to neverchanged.

  • 8/8/2019 25SpER Model YenChuPan

    7/17

    Single/M

    ulti-valued attributes Single-valued attributes are attributes that

    only have a single value for a particular

    entity. Multi-valued attributes refers to items that

    are not singled-value and Null valued. Forexample, consider an employee entity set

    with the attribute phone-number. Anemployee may have zero, one, or severalphone numbers; different employee mayhave different numbers of phones.

  • 8/8/2019 25SpER Model YenChuPan

    8/17

  • 8/8/2019 25SpER Model YenChuPan

    9/17

    Mapping Cardinalities or

    Cardinality ratios Express the number of items to which another item

    can be associated via a relationship set

    Are most useful in describing binary relationshipsets. For a binary relationship set R between entitysets A and B, the mapping cardinality must be oneof the following: One to One

    One to Many

    Many to One

    Many to Many

  • 8/8/2019 25SpER Model YenChuPan

    10/17

    Participation Constraints

    The participation of an entity set E in a

    relationship set R is said to be total, if

    every item in E participates in at least

    one relationship in R. If only some

    items in E participate in relationship R,

    the participation of entity set E inrelationship R is said to bepartial.

  • 8/8/2019 25SpER Model YenChuPan

    11/17

    Weak Entity Sets

    There is an occasional condition in

    which an entity sets key is composed

    of attributes some or all of which

    belong to another entity set. Such an

    entity set is called a weak entity set.

  • 8/8/2019 25SpER Model YenChuPan

    12/17

    Discriminator The discriminator of a weak entity setis a

    set of attributes that allows this distinction to

    be made. For example, the discriminator ofa weak entity set payment is the attribute

    payment-number, since, for each loan a

    payment number uniquely identifies one

    single payment for that loan. Thediscriminator of a weak entity set is also

    called the partial key of the entity set.

  • 8/8/2019 25SpER Model YenChuPan

    13/17

    Requirements forWeak Entity

    Sets We cannot obtain key attributes for a weak

    entity set indiscriminately. Rather, if E is a

    weak entity set then its key consists of: Zero or more of its own attributes, and

    Key attributes from entity sets that are reached

    by certain many-one relationship from E to other

    entity sets. These many-one relationship arecalled supporting relationships for E.

  • 8/8/2019 25SpER Model YenChuPan

    14/17

    Discriminator (cont.) Note: although each payment entity is

    distinct, payments for different loans may

    share the same payment-number. Thus,payment entity set does not have a primary

    key; it is a weak entity set.

    The primary key of a weak entity set is

    formed by the primary key of the identifyingentity set, plus the weak entity sets

    discriminator.

  • 8/8/2019 25SpER Model YenChuPan

    15/17

    Identifying aW

    eak Entity Type A Weak entity type doesnt have a primary key.

    If X is a weak entity type and Y is the entity typeon which X is dependent.

    We form a primary key for X by combining theprimary key of Y which one or more attributes,called discriminatororpartial key, from X.

    In an E/R Diagram, a partial key is usually dash-

    underlined. e.g., primary key for DEPENDENT: {Employee No.,

    DName}.

  • 8/8/2019 25SpER Model YenChuPan

    16/17

    * Doted-line = double-line

    *

  • 8/8/2019 25SpER Model YenChuPan

    17/17

    References Peter Chens website:

    http://bit.csc.lsu.edu/~chen/chen.html

    Database Systems: A First Course, J.D.Ullman & J. Widom

    http://www-db.stanford.edu/~ullman/fcdb.html

    http://www.cs.sjsu.edu/faculty/lee/cs157/25S

    p157AL4.ppt http://www.cs.sjsu.edu/faculty/lee/cs157/25S

    p157AL5Enhanced%20ER-diagram.ppt