er diagrams[1]

26
ER diagrams

Upload: shivankaperera5665

Post on 10-Sep-2015

226 views

Category:

Documents


0 download

DESCRIPTION

ER Diagrams[1]

TRANSCRIPT

  • ER diagrams

  • What are Entity Relationship Diagrams?

    Entity Relationship Diagrams (ERDs) illustrate the logical structure of databases.

  • Cardinality

    Cardinality specifies how many instances of an entity relate to one instance of another entity.

  • Recursive relationship

    In some cases, entities can be self-linked. For example, employees can supervise other employees.

  • Entity Classes and AttributesEntity Classare represented by rectanglesAttributesare represented by ovalsKey attributeis represented by an underlineMultivalued attributesis represented with an oval with a double borderDerived attributeis represented with an oval dashed border -- Example the AGE from current - birthComposite attributeis represented with an oval that connects to additional ovals

  • E-R Diagram for Entity ClassCustomer

  • E-R diagram for the entity class Video.

  • Relationship Types and Constraints a store owns a video

  • A relationship type is represented by a diamond and two connecting lines. The name of the relationship is shown inside the diamond. Reading the diagram from left to right to yields "a store owns a video"..The name of the relationship type is a verb or verb phrase that describes the relationship.The alternate relationship name IsOwnedBy is the name of the relationship type when reading the other direction.

  • E-R Diagram for theOwnsRelationship Type Showing Cardinality and Participation Constraints

  • A relationship between the customer and the video is created when the customer rents the video. The relationship is removed when the customer returns the video.

  • E-R Diagram of Relationship TypePreviouslyRented

  • capture the history with using previous information.

    The relationship type PreviouslyRented is many-to-many because each customer may have previously rented many videos and each video may have been rented many times. The participations are optional for both customers and videos.

  • E-R Diagram of a Combined Current and Previous Rental Relationship Type

  • Modeling Rentals as an Entity Classlook at this is rental as an entity and not simply a relationship.

  • referring to a "rental" as an object Each rental entity has three attributes: date Due, dateRented, and cost The relationship types are calledHas.These are the relationship sentences for the diagram.A customer may have many rentals.A rental must have one customer.A rental must have one video.A video may have no more than one rental

  • An E-R Diagram Showing Weak Entity ClassRental

  • -have an entity with no distinguishing attributes that is partly identified by its relationship to other entities.

    -call this a weak entity and class Rental a weak entity class.

  • Roles in Relationship Types

    Relationship TypesIsMarriedToandIsChildOf,with Role Names

  • A person may be the child of one or two parents

    A person may be the parent of zero or more children

    A person may be the wife of a husband

    A person may be the husband of a wife