Entity-Relationship-Modeling.pdf
Document Details
Tags
Full Transcript
Entity-Relationship Modeling ER-modeling is a data modeling method used in software engineering to produce a conceptual data model of an information system. Diagrams created using this ER-modeling method are called Entity-Relationship Diagrams or ER diagrams or ERDs. The purpose of ERD is to he...
Entity-Relationship Modeling ER-modeling is a data modeling method used in software engineering to produce a conceptual data model of an information system. Diagrams created using this ER-modeling method are called Entity-Relationship Diagrams or ER diagrams or ERDs. The purpose of ERD is to help the database analyst gain a better understanding of the data to be contained in the database, serve as a documentation tool, and connect the logical structure of the database to users. Entities and Entity Sets An entity can be a real-world object, either animate or inanimate, that can be merely identifiable. An entity is denoted as a rectangle in an ER diagram. Entity Entity Set A real-world object that can be identified. A collection of related types of entities. For example, a Student set may contain all the students of a school. Attributes Entities are denoted utilizing their properties, known as attributes. All attributes have values. For example, a student entity may have name, class, and age as attributes. There exists a domain or range of values that can be assigned to attributes. For example, a student's name cannot be a numeric value. It has to be alphabetic. A student's age cannot be negative, etc. 1 Key Attribute Uniquely identifies an entity among the entity set. For example, the roll_number of a student makes him identifiable among students. 2 Composite Attribute A combination of other attributes. For example, In student entity, the student address is a composite attribute as an address is composed of other characteristics such as pin code, state, country. 3 Single-valued Attribute Contains a single value. For example, Social_Security_Number 4 Multi-valued Attribute Can have more than one value. For example, a person can have more than one phone number, email address, etc. 5 Derived Attribute Derived attributes are the attribute that does not exist in the physical database, but their values are derived from other attributes present in the database Types of Keys There are mainly three types of keys: ⮚ Super key: A set of attributes that collectively identifies an entity in the entity set. ⮚ Candidate key: A minimal super key is known as a candidate key. An entity set may have more than one candidate key. ⮚ Primary key: A primary key is one of the candidate keys chosen by the database designer to uniquely identify the entity set. Super Key Candidate Key Primary Key A set of attributes A minimal super One of the that uniquely key. candidate keys identifies an chosen by the entity. database designer. Relationships The association among entities is known as relationship. Relationships are represented by the diamond-shaped box. For example, an employee works_at a department, a student enrolls in a course. Here, Works_at and Enrolls are called relationships. Entity 1 Employee Relationship Works_at Entity 2 Department Relationship Sets A set of relationships of a similar type is known as a relationship set. Like entities, a relationship too can have attributes. These attributes are called descriptive attributes. Relationship The association between entities. Relationship Set A collection of relationships of the same type. Descriptive Attributes Attributes that describe the relationship. Degree of a Relationship Set The number of participating entities in a relationship describes the degree of the relationship. The three most common relationships in E-R models are: 1) Unary (degree1) - This is also called recursive relationships. It is a relationship between the instances of one entity type. For example, one person is married to only one person. Unary Binary Ternary Relationship between instances of one Relationship between instances of two Relationship between instances of three entity type. entity types. entity types. Cardinality Cardinality describes the number of entities in one entity set, which can be associated with the number of entities of other sets via relationship set. Types of Cardinalities 1. One to One: One entity from entity set A can be contained with at most one entity of entity set B and vice versa. Let us assume that each student has only one student ID, and each student ID is assigned to only one person. So, the relationship will be one to one. 1 One to One One entity from entity set A can be associated with at most one entity of entity set B and vice versa. 2 One to Many When a single instance of an entity is associated with more than one instances of another entity. 3 Many to One More than one entity from entity set A can be associated with at most one entity of entity set B, however an entity from entity set B can be associated with more than one entity from entity set A. 4 Many to Many One entity from A can be associated with more than one entity from B and vice-versa. Many to Many Relationships One entity from A can be associated with more than one entity from B and vice-versa. For example, the student can be assigned to many projects, and a project can be assigned to many students. Many to Many One entity from A can be associated with more than one entity from B and vice-versa.