Stephen C. Hayne Data Modeling zMethod yidentify/describe data entities zNotation yway to illustrate findings zApproaches yNormalization yEntity Relationship
Entity Relationship Model zStrong and weak entity types zAttributes zBinary relationships zDesign problems zRecursion and generalization
Stephen C. Hayne Basic concepts zEntity yidentifiable object or concept zAttribute yproperty of an entity or relationship zRelationship yan association among entities zIdentifier yone or more attributes identifying an instance of an entity
Stephen C. Hayne Entity (or entity class) vs. entity instance
Stephen C. Hayne Entity types zStrong yexistence does not depend on the existence of another entity zWeak yexistence is dependent on the existence of another entity ybusiness rules vs. logical dependence yID-dependence (physical dependence)
Stephen C. Hayne Entity-Relationship Model Relationship Identifying Relationship Entity Weak Entity
Stephen C. Hayne Entity examples Staff Branch Next of Kin Room zWhich are strong, weak, ID-dependent entities?
Stephen C. Hayne Attributes or properties DORMITORY Location DormName Number of Rooms DORMITORY DormName Location Number of Rooms
Stephen C. Hayne Identifiers zNon-unique yLastName zUnique (key) ySSN zComposite y{AreaCode, LocalNumber} y(is this unique?)
Stephen C. Hayne Binary relationships: HAS-A IsAssignedOccupies BelongsTo
Stephen C. Hayne Binary Relationship StudentClass 0:N0:35 IsEnrolledIn Partial Participation
Stephen C. Hayne Binary Relationship StudentClass 1:N IsEnrolledIn Total Participation
Stephen C. Hayne Ternary relationships zCan often (always) split one relationship of degree 3 into two (three) relationships of degree 2; are these independent?...
Stephen C. Hayne More on relationships zRelationship classes vs. instances zRelationships can have attributes (equivalent to degree=3) zCrows feet representation of cardinality Rent
Stephen C. Hayne Cardinality zNumber of elements allowed on each side of a relationship (participants) zMaximum Cardinality yMaximum number of entities that can be involved in relationship: typically 1 or many zMinimum Cardinality yMinimum number of entities that MUST be involved in relationship : typically 0 or 1 yAlso called participation constraints: total or partial
Stephen C. Hayne Cardinality constraints PROPERTYOWNER 1:N Owns AUTOEMPLOYEE 1:1 Assigned CLUBSTUDENT N:M Joins
Stephen C. Hayne Fan traps zMultiple 1:N relationships from the same entity where a relationship between child entities is required zSolve it!
Stephen C. Hayne Fan traps Solution
Stephen C. Hayne Chasm traps zMissing a required pathway between entities zSingle line: partial participation zSolve it!
Stephen C. Hayne Chasm traps Solution
Stephen C. Hayne Recursive relationships zParticipants are instances of same class
Stephen C. Hayne Recursive Relationship Volunteer Supervisor Supervisee Supervises Role Name 0:N 1:1
Stephen C. Hayne Weak relationship zRelationships involving weak entities yLogical dependency yID-dependency
Stephen C. Hayne A full E-R diagram example zProperties can be shown in the diagram or listed separately
Stephen C. Hayne Supertype & subtype entities zExclusive vs. non-exclusive subtypes zRequired vs. optional subtypes
Stephen C. Hayne Generalization hierarchy zRepresented by supertypes & subtypes zAlso called: ytype hierarchy yIS-A relationships zInheritance ysubtype entities inherit attributes of supertype entity
Stephen C. Hayne Putting it together zAdd business rules yConstraints, restrictions, protocols yDocument the rules zEvaluate your data model! yWhat queries can you pose? yAre there any connection traps? yDoes it model the users model of the business world?
Stephen C. Hayne Form pairs Find: 1 business rule 1 query Share