The Entity-Relationship (ER) Model is a conceptual framework used in database design to visually represent the structure of a database and the relationships between data entities. The ER model is widely used for database design because it helps in visualizing data requirements and forming a blueprint for creating a relational database.
The ER model uses entities, attributes, and relationships to describe the data requirements of a system.
Entities
An entity is an object or thing in the real world that has a distinct existence. It represents a set of objects that share the same properties or characteristics. Entities can be physical objects (e.g., a car, an employee, a department) or abstract concepts (e.g., a project, an event).
Example:
An entity set called Employee could include entities such as:
Entity Diagram: Entities are typically represented as rectangles in an ER diagram.
Attributes
An attribute is a property or characteristic that describes an entity. Attributes represent the data that the system will store for each entity.
Age, EmployeeID).Full Name could be divided into First Name and Last Name).Age derived from Date of Birth).Phone Numbers).Example:
For the Employee entity, some possible attributes could be:
Attribute Diagram: Attributes are represented as ovals connected to their respective entities.
Relationships
A relationship represents an association between two or more entities. It shows how entities interact with each other.
Example:
Relationship Diagram: Relationships are represented by diamonds in an ER diagram. The entities involved are connected to the relationship by lines.
Primary Keys
A primary key is an attribute or a set of attributes that uniquely identifies each entity instance. It must be unique for every record in the entity set.
Example:
For the Employee entity, EmployeeID could be a primary key because it uniquely identifies each employee.
Primary Key Diagram: The primary key is usually underlined in the ER diagram.
Weak Entities
A weak entity is an entity that cannot be identified by its own attributes alone. It requires a strong (owner) entity to ensure its uniqueness. A weak entity typically has a partial key and is dependent on the strong entity for identification.
Example:
A Dependent entity might be a weak entity in a relationship with an Employee entity, where a dependent cannot be uniquely identified without reference to the employee.
Chen’s Notation:
This is the traditional form of the ER model introduced by Peter Chen. In Chen's notation:
Crow’s Foot Notation:
This is a more modern and popular variation of the ER model. It uses:
UML Notation:
Unified Modeling Language (UML) can also be used to model databases, using class diagrams to represent entities and relationships.
Let's consider an example of a university database that includes students, courses, and instructors:
StudentID, Name, DOBCourseID, CourseNameInstructorID, NameGrade (Optional, could store a grade received by a student in a course).ER Diagram Representation:
[Student] -----< Enrollment >----- [Course] -----< Teaches >----- [Instructor]
| |
[StudentID] [CourseID] [InstructorID]
| |
[Name] [CourseName] [Name]
Identify Entities:
Identify all the objects (or things) that need to be represented in the system. These will become the entities in the ER diagram.
Identify Relationships:
Define how the entities are related to each other. Relationships should capture how entities interact with each other.
Define Attributes:
Determine what attributes (properties) each entity should have. Attributes describe characteristics of entities.
Define Primary Keys:
For each entity, choose a primary key that uniquely identifies instances of the entity.
Define Cardinality:
Determine the nature of relationships between entities (one-to-one, one-to-many, many-to-many).
Normalization:
Apply normalization rules to ensure the database structure is efficient, removing redundancy and dependency issues.
The Entity-Relationship Model (ER Model) is a vital tool in the conceptual design phase of database development. It helps to define the structure of the database by identifying entities, attributes, and relationships and then representing these visually in a diagram. The ER model guides the creation of efficient, logical database designs that are easy to understand and implement.
Open this section to load past papers