330 likes | 625 Views
Entity‐Relationship Model is a detailed, logical representation of the data for an organization or for a business area. What are the entities and relationships in the enterprise?
E N D
Entity‐Relationship Model is a detailed, logical representation of the data for an organization or for a businessarea. • What are the entities and relationships in the enterprise? • What information about these entities and their relationships should we store in thedatabase? • What are the integrity constraints or business rules thatholds? • The model must be as ‘open’ as possible and not tied to any technology or to any particular businessmethodology. • Introduced in 1976 by PeterChen. Overview of Entity‐RelationshipModel ISE230
The E‐R model is usually expressed as an E‐R diagram. • Widespread CASEtool‐support • No standard notation for E‐Rmodeling/diagram. • Chen, Martin, Crow Foot and many othernotations. • E‐R Model is the mainstream approach for data modeling. • Communication tool between variousstakeholders. Overview of Entity‐Relationship Model(2) ISE230
Term – word or phrase with specificmeaning • Examples: course, rental car, flight,reservation • Fact – association between two or moreterms • ‘A course is a module of instruction in a particular subject area’ • ‘A customer may request a model of a car from a rental branch on a particulardate’ • A good data definitionis: • Related to business, not technical,characteristics • Meaningful andself‐documenting • Composed of words from an approvedlist. Data Definitions in DataModeling ISE230
Entity: A person, place, object, event, or concept in the user environment about which the organization wishes to maintaindata. • More examples on page 93 and 94 of 8thEdition. • Entity Type (or Entity Set) – collection ofentities • Often corresponds to atable. • Entity instance – A single occurrence of an entitytype. • Often corresponds to a row in atable. Entities and EntitySets Player Match Team Ground ISE230
SHOULDBE: • An object that will have many instances in thedatabase. • An object that will be composed of multiple characteristics/attributes. • SHOULD NOTBE: • A user of the database system. • An output of the database system (e.g., areport). • Rules (conventions) for namingentities. • Singular (e.g. Player) vs. Plural names (e.g.Players) What Should an EntityBe? ISE230
Property or characteristic of an entityset. • An entity is represented by a set of attributes, that is descriptive properties possessed by all members of an entityset. • Examples: Player name, Career runs, Number of centuries scored,etc. • Domain: The set of permitted values for eachattribute. • Rules/Conventions for naming attributestoo. Attributes ISE230
Simple vs. CompositeAttribute • Single‐Valued vs. Multi‐valuedAttribute • Stored vs. DerivedAttributes • IdentifierAttributes • Required vs. OptionalAttributes AttributeClasses ISE230 10
An attribute broken into many parts: compound data values. CompositeAttributes ISE230
Multiple data values for one attribute areallowed Multi‐valuedAttributes ISE230
Value can be computed from otherattributes • Example: Age, given Date ofBirth • CareerRuns DerivedAttributes Centuries PlayerName Player Average ISE230
Identifier (orKey)is an attribute (orcombinationof attributes) that uniquely identifies individual instances of an entitytype • Simple vs. CompositeIdentifier Identifiers (akaKeys) Date FlightNumber Destination FlightID Flight ISE230
Will not change invalue • No intelligent/dynamic identifiers (e.g., containing locations or people that mightchange) • Example: Captain’s name as an identifier of the team (YYoounisElevenn)) • Will not benull/empty • It is recommended to substitute new, simple keys for long, compositekeys • Candidate Identifier is an attribute that could be akey • It satisfies the requirements for being anidentifier Characteristics ofIdentifiers ISE230
Links/Association between entities – modeled as connectinglines. • Relationship Types: Modeled as association between entitytypes Relationships • Relationship Instances: Links between specific entity instances • PlayerTeam Inzimam‐ul‐Haq BrianLara RanaNaveed Pakistan LahoreBadshah WestIndies SachinTendulkar India ISE230
One‐to‐One • Each entity in the relationship will have exactly one related entity • One‐to‐Many • An entity on one side of the relationship can have many related entities, but an entity on the other side will have a maximum of one relatedentity • Many‐to‐Many • Entities on both sides of the relationship can have many related entities on the otherside Cardinality ofRelationships ISE230
Cardinality Constraints ‐ the number of instances of one entity that can or must be associated with each instance of anotherentity • MinimumCardinality • If zero, then relationship isoptional • If one or more, then mandatory (MUSThold) • MaximumCardinality • The maximum number of entity instances that could be association with the target entity in therelationship. CardinalityConstraints ISE230
One entity instance associated with only (maximum) one target entity instance One‐to‐OneRelationship A manager isassociated One team is managedby with only one team at most, or there is no manager. only one manager atmost or not managed atall. ISE230 20
Optionalcardinalities One‐to‐One Relationship(2) A person is married to at most oneother person, or may not be married atall ISE230
Many entity instances associated with either optionally or mandatory many target entityinstances Many‐to‐ManyRelationship Many teams can have same or many players. One or more players are associated with none or moreteams. ISE230
One entity instance associated with optionally or mandatory many target entityinstances. One‐to‐ManyRelationship ISE230
Entities can be related to one another in more than one way • Employees anddepartments Examples of multiplerelationships ISE230
Examples of multiplerelationships • Professors and courses (fixed upper limitconstraint) ISE230
Degree of a relationship is the number of entity types that participate init • UnaryRelationship • BinaryRelationship • TernaryRelationship Degree ofRelationships ISE230
Degree of relationships:Notations Entities of two different types related to eachother One entity related to another of the same entitytype Entities ofthree different types related to each other ISE230 27
Degree of relationships:Examples • a) Unaryrelationships ISE230
Degree of relationships:Examples • b) Binaryrelationships ISE230
c) Ternaryrelationship Degree of relationships:Examples Note: a relationship can have attributes of itsown ISE230 30
Binary Relationships withAttributes Here, the date completed attribute pertains specifically to the employee’s completion of a course…it is an attribute of therelationship ISE230 31
An associative entity(CERTIFICATE) Associative entity is like a relationship with an attribute, but it is also considered to be an entity in its ownright. Note that the many‐to‐many cardinality between entities in previous figure has been replaced by two one‐to‐many relationships with the associativeentity. ISE230
When should a relationship with attributes instead be an associativeentity? • All relationships for the associative entity should bemany • The associative entity could have meaning independent of the otherentities • The associative entity preferably has a unique identifier, and should also have otherattributes • The associative entity may participate in other relationships other than the entities of the associatedrelationship • Ternary relationships should be converted to associativeentities AssociativeEntities ISE230
Multi‐valued Attributes vs.Relationships simple composite ISE230
Strong Entity Type: One that exists independently of other entitytypes. • Strong entity instances always have a uniqueidentifier • Identifier is underlined withsingle‐line • Examples: Student, Employee,Course • Weak Entity Type: One whose existence depends on a strong entity (called Identifying Owner). • It only has a partialidentifier • Partial identifier is underlined withdouble‐line • Entity box has doubleline • Example: Employee versusEmployeeCredentials Strong vs. WeakEntities ISE230
Summary • Basic business rules are data names anddefinitions • Data modeling notations frequently used today is the entity‐relationship datamodel. • E‐R model constructs: entities, entity types, relationships, relationship types, attributes, identifiers, cardinality constraints. • EssentialReading • Modern Database Management (8th Ed.), Chapter3 • What isNext? • More on ER and Enhanced E‐RModel Conclusion ISE230