1 / 30

Entity Relationship Model

Entity Relationship Model. Basic Concepts: Database Modeling: A database can be modeled as a collection of entities and relationship among entities. Entity Relationship Model:

feliciac
Télécharger la présentation

Entity Relationship Model

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Entity Relationship Model Basic Concepts: Database Modeling: A databasecan be modeled as a collection of entities and relationship among entities. Entity Relationship Model: The entity-relationship model (or ER model) is a way of graphically representing the logical relationships of entities (or objects) in order to create a database. The ER model was first proposed by Peter Pin-Shan Chen in the 1970s.

  2. Entities: • In general, an entity is an existing or real thing. • It is a “thing” or “object” in the real world that is distinguishable from all other objects. • These are the people, places, things, events and concepts of interest to an organization. • An entity has a set of properties and the values for some set of properties may uniquely identify an entity. • Entities represent collections of things. • For example, an EMPLOYEE entity might represent a • collection of all the employees that work for an organization. • Individual members (employees) of the collection are called occurrences of the EMPLOYEE entity.

  3. Attributes: • An entity is represented by a set of attributes, that is descriptive properties possessed by all members of an entity set. • Attributes are the properties that are used to describe an entity. • Example an EMPLOYEE entity may have a Name, SSN, Address, Sex, BirthDate. • A specificentity will have a value for each of its attributes. • Example a specific employee entity may have Name='John Smith', SSN='123456789', Address='731 Fondren, Houston, TX', Sex='M', BirthDate='09-JAN-55'.

  4. Types of Attributes: • Simple Attributes: Each entity has a singleatomicvalue for the attribute; for example SSN or Sex. 2. Composite: Composite attributes are the attributes that are composed of several components; for example Address (Apt, House, Street, City, State, ZipCode, Country) or Name (FirstName, MiddleName, LastName).

  5. 3.Multi-valued: • An entity may have multiplevalues for that attribute. • Example Color of a CAR or PreviousDegrees of a STUDENT. • Denoted as {Color} or {PreviousDegrees}. 4. Single Values Attributes: • Attributes having single value for a particular entity are called as single valued attributes. • Example, Age is a single value for a particular entity Person.

  6. 5. Stored Attributes: • An attribute whose value is actually stored in a database is called as a stored attribute. 6. Derived Attributes: • In some cases two or more attribute values are related. • Example the age and Birthdate attributes of a person. • For a particular person entity, the value of Age can be determined from the current date and the value of that person’s Birthdate. • The Age attribute is hence caleed as derived attribute. Domain: Domain is the set of permitted values for each attribute.

  7. Entity Sets customer and loan Customer Customer Customer customer Loan Amount ID name street City number

  8. Relationship: • A relationship relates two or more distinct entities with a specific meaning. • It is an association among several entities. • Example: Hayes depositorA102 Customerentityrelationship setAccountentity

  9. Relationship Set: • A relationship setis a mathematical relation among n >= 2 entities, each taken from entity sets. where (e1, e2, …, en) is a relationship Example: (Hayes, A102) Єdepositor {(e1, e2, … en) | e1 ЄE1, e2 ЄE2, …, en ЄEn}

  10. Relationship Set borrower:

  11. An attributecan also be property of a relationship set. • For instance, the depositorrelationship set between entity sets customer and accountmay have the attribute access_date.

  12. Degree of a Relationship Set: • Refers to number of entity sets that participate in a relationship set. • Relationship sets that involve two entity sets are binary (or degree two). • Generally, most relationship sets in a database system are binary. • Relationship sets may involve more than two entity sets. • Example: Suppose employees of a bank may have jobs (responsibilities) at multiple branches, with different jobs at different branches. • Then there is a ternary relationship set between entity sets employee, job, and branch.

  13. Mapping Cardinalities: • Thecardinality ratio for a binary relationship specifies the number of relationship instances that an entity can participate in. • Note: Some elements in A and B may not be mapped to any elements in the other set One to One One to Many

  14. Many to One Many to Many

  15. Keys: Super Key: A superkeyof an entity set is a set of one or more attributes whose values uniquely determine each entity. Candidate Key: A candidatekeyof an entity set is a minimal super key E.g. Customer_idis candidate key of customer and account_numberis candidate key of account. Primary Key: Although several candidate keys may exist, one of the candidate keys is selected to be the primarykey. Primary key is an attribute which uniquely identifies each entity in an entity set.

  16. Keys for Relationship Sets: • The combination of primary keys of the participating entity sets forms a super key of a relationship set. • (customer_id, account_number) is the super key of depositor. • NOTE: Thismeans a pairofentitysetscanhaveatmostonerelationshipinaparticularrelationshipset.

  17. E-R Diagram Notations:

  18. ER Diagram With Composite, Multivalued, and Derived Attributes:

  19. Relationship Sets with Attributes:

  20. Roles: • Entity sets of a relationship need not be distinct. • The labels “manager” and “worker” are called roles; they specify how employee entities interact via the works_for relationship set. • Roles are indicated in ER diagrams by labeling the lines that connect diamonds to rectangles. • Role labels are optional, and are used to clarify semantics of the relationship.

  21. Cardinality Constraints: • Cardinality constraints are expressed by drawing either a directed line ( )signifying “one,” or an undirected line (—), signifying “many,” between the relationship set and the entity set. One to one relationship: • A customer is associated with at most one loan via the relationship borrower. • A loan is associated with at most one customer via borrower.

  22. One To Many Relationship: • In the one to many relationship a loan is associated with at most one customer via borrower, a customer is associated with several (including 0) loans via borrower. Many To One Relationships: • In a many to one relationship a loan is associated with several (including 0) customers via borrower, a customer is associated with at most one loan via borrower Many To Many Relationship: • A customer is associated with several (possibly 0) loans via Borrower, A loan is associated with several (possibly 0) customers via borrower.

  23. Relationship Set: • Total participationis indicated by double line: every entity in the entity set participates in at least one relationship in the relationship set. • E.g. participation of loan in borrower is total. • Every loan must have a customer associated to it via borrower. • Partial participation:Some entities may not participate in any relationship in the relationship set. • Example: participation of customer in borrower is partial.

  24. ER Diagram with a Ternary Relationship:

  25. Weak Entity Sets: • An entity set that does not have a primary key is referred to as a weak entity set. • The existence of a weak entity set depends on the existence of a identifying entity set. • It must relate to the identifying entity set via a total, one to many relationship set from the identifying to the weak entity set. • Identifying relationship is depicted using a double diamond. • The discriminator(or partial key) of a weak entity set is the set of attributes that distinguishes among all the entities of a weak entity set. • The primary key of a weak entity set is formed by the primary key of the strong entity set on which the weak entity set is existence dependent, plus the weak entity set’s discriminator.

  26. We depict a weak entity set by double rectangles. • We underline the discriminator of a weak entity set with a dashed line. • payment_number – discriminator of the payment entity set • Primary key for payment – (loan_number, payment_number).

More Related