er diagram

Upload: nave101

Post on 30-Oct-2015

103 views

Category:

Documents


0 download

DESCRIPTION

er-diagram for database

TRANSCRIPT

  • **Yan Huang - ERChapter 6: ER Entity Relationship DiagramMajor components of ER diagramPractices

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERER1976 proposed by Peter ChenER diagram is widely used in database designRepresent conceptual level of a database systemDescribe things and their relationships in high level

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERBasic ConceptsEntity set an abstraction of similar things, e.g. cars, students An entity set contains many entitiesAttributes: common properties of the entities in a entity setsRelationship specify the relations among entities from two or more entity sets

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERAn Example

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERRelationshipA relationship may be thought as a set as wellFor binary relationship, it enumerates the pairs of entities that relate to each otherFor example, entity set M = {Mike, Jack, Tom} entity set F = {Mary, Kate}. The relationship set married between M and F may be {,}

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERRelationshipA relationship set is a mathematical relation among n 2 entities, each taken from entity sets{(e1, e2, en) | e1 E1, e2 E2, , en En} where (e1, e2, , en) is a relationshipExample: (Hayes, A-102) depositor

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERRelationship Example

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERAttribute of A Relationship Set

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERRelationshipThe degree of a relationship = the number of entity sets that participate in the relationshipMostly binary relationshipsSometimes moreMapping cardinality of a relationship1 11 manymany 1Many-many

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - EROne-One and One-Many

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERMany-one and many-many

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ER1- many

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERMany - 1

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERMany - many

    Yan Huang -CSCE4350 - ER

  • **Yan Huang -CSCE4350 - ERAlternative Cardinality Specification

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERNote on Mapping CardinalityBoth many and 1 include 0Meaning some entity may not participate in the relationship

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERTotal ParticipationWhen we require all entities to participate in the relationship (total participation), we use double lines to specify Every loan has to have at least one customer

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERSelf RelationshipSometimes entities in a entity set may relate to other entities in the same set. Thus self relationshipHere employees mange some other employeesThe labels manger and worker are called roles the self relationship

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERMore examples on self-relationshipPeople to peopleParent childrenManager employeeHusband wifeWord to wordRoot synonym

    Yan Huang -CSCE4350 - ER

  • **Yan Huang 350 - ERAttributesBoth entity sets and relationships can have attributesAttributes may beComposite Multi-valued (double ellipse)Derive (dashed ellipse)

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERAnother Example

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERKeysA super key of an entity set is a set of one or more attributes whose values uniquely determine each entity.A candidate key of an entity set is a minimal super keyAlthough several candidate keys may exist, one of the candidate keys is selected to be the primary key.

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERKey ExamplesSuggest super keys for the following entity?What are the candidate keys?Primary key?

    authornamebirthdaydeathdescription

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - - ERTernary Relationship

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERCan We Decompose a Ternary Relationship?Some relationships that appear to be non-binary may be better represented using binary relationshipsE.g. A ternary relationship parents, relating a child to his/her father and mother, is best replaced by two binary relationships, father and motherUsing two binary relationships allows partial information (e.g. only mother being know)But there are some relationships that are naturally non-binaryE.g. works-on, why?

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERConverting Ternary to binaryIn general, any non-binary relationship can be represented using binary relationships by creating an artificial entity set.Replace R between entity sets A, B and C by an entity set E, and three relationship sets: 1. RA, relating E and A 2.RB, relating E and B3. RC, relating E and CCreate a special identifying attribute for EAdd any attributes of R to E For each relationship (ai , bi , ci) in R, create 1. a new entity ei in the entity set E 2. add (ei , ai ) to RA 3. add (ei , bi ) to RB 4. add (ei , ci ) to RC

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERConverting Ternary to binary

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERDesign an ER DiagramDesign a database for an on-line reservation system for microscopes in material science labThere are two types of users: microscope administrators and microscope end usersEach microscope is located in a specific labEach request is assigned to an administrator who can authorize or deny the requestUsing of some microscope requires the presence of an administratorTime is divided into 1 hour slots. Each reservation can only take one or more time slots

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERWeak Entity SetSome entity sets in real world naturally depend on some other entity set They can be uniquely identified only if combined with another entity setExample:section1, section2, become unique only if you put them into a context, e.g. csce4350

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERWeak Entity Set NotationsDouble rectangles for weak entity setDouble diamond for weak entity relationshipDashed underscore for discriminator

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERSpecializationA lower-level entity set inherits all the attributes and relationship participation of the higher-level entity set to which it is linked.A lower-level entity set may have additional attributes and participate in additional relationships

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ER

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERSpecificationDisjointCompleteness constraint (use double lines)total : an entity must belong to one of the lower-level entity setspartial: an entity need not belong to one of the lower-level entity sets

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERDesign ConsiderationsUse of entity sets vs. attributesWhether we want to keep additional informationUse of entity sets vs. relationship setsActions among entities are usually represented by relationshipsBinary versus n-ary relationship setsN-nary relationships are usually more natural for actions among entity setsWeak entity set vs. strong entity setGeneralization

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERNotations

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERNotations

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERER Practice AgainDesign an ER diagram for an online music store. The database will contain at least the following concepts: songs, artists, bands, albums, and genres. State your design assumptions you make to support design decisions. Be sure your assumptions are reasonable.

    Yan Huang -CSCE4350 - ER

  • **Yan Huang CE4350 - ERBest Practice Guide for ER DesignUse of entity sets vs. attributesUse of entity sets vs. relationship setsBinary versus n-ary relationship setsWeak entity set vs. strong entity setChoose the natural oneGeneralizationIf specialized entities need to keep additional information and participate in additional relationships

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERER for Banking EnterpriseDescription handhout

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ERRead ER DiagramsFollowing are some ER diagrams grabbed from the webRead to understand/criticize

    Yan Huang -CSCE4350 - ER

  • **Yan Huang - ER?????????

    Yan Huang -CSCE4350 - ER

  • **Yan Huang -CSCE4350 - ER?????

    Yan Huang -CSCE4350 - ER

  • **Yan Huang -CSCE4350 - ER?

    Yan Huang -CSCE4350 - ER

  • **Yan Huang -CSCE4350 - ER

    Yan Huang -CSCE4350 - ER

    ********************************************