ENTITY RELATIONSHIP MODEL
The Entity-Relationship Model (ER Model) is a conceptual framework used to
represent the structure of a database in terms of entities, attributes, and
relationships. It is a visual tool for database designers to map out the logical
structure of a system before implementing it in a database management
system (DBMS).
The ER Model was introduced by Peter Chen in 1976 and is one of the
foundational concepts in database design.
Entities:
Entities represent real-world objects or concepts within the domain
being modeled. They are depicted as rectangles in ER diagrams.
Examples: In a university database, entities might include Student,
Course, and Instructor.
Attributes:
Attributes are properties or characteristics of entities, describing
specific details about them. They are shown as ovals connected to
their respective entities in an ER diagram.
Types of attributes:
o Simple Attribute: Has a single, indivisible value (e.g., Name,
Age).
o Composite Attribute: Can be divided into smaller sub-
attributes (e.g., Address might be divided into Street, City, and
Zip Code).
o Derived Attribute: Calculated from other attributes (e.g., Age
can be derived from DateOfBirth).
o Multivalued Attribute: Can hold multiple values for a single
entity instance (e.g., Phone Numbers).
Relationships:
Relationships define how two or more entities are associated with each
other and are represented by diamonds in ER diagrams.
Types of relationships:
o One-to-One (1:1): Each instance of an entity is associated with
only one instance of another entity.
o One-to-Many (1): One instance of an entity is associated with
multiple instances of another entity.
o Many-to-Many (M): Multiple instances of one entity are
associated with multiple instances of another entity. This is often
implemented through an intermediate table in a relational
database.
Primary Keys and Foreign Keys:
Primary Key: A unique identifier for each instance of an entity (e.g.,
StudentID for Student).
Foreign Key: An attribute that creates a link between entities by
referencing a primary key in another table.
ENTITY RELATONSHIP DIAGRAM
The ER Model is typically represented by an ER Diagram (ERD), a visual
representation that uses symbols to depict entities, attributes, and
relationships:
Rectangles for entities.
Ovals for attributes connected to their entities.
Diamonds for relationships between entities.
Lines to show connections between entities and their attributes or
relationships.
Advantages of the ER Model
Simplifies Complex Data Structures: Helps in breaking down
complex data structures into a clear visual representation.
Logical Data Mapping: Provides a blueprint for implementing the
logical design in a relational database.
Improves Communication: Allows database designers, developers,
and stakeholders to discuss the system using a common framework.
Minimizes Redundancy: Helps identify areas of data duplication or
redundancy, improving the efficiency of the database design.
Example of an ER Model
For a Library database:
Entities: Book, Author, Member, Loan.
Attributes: Book has attributes like Title, ISBN, Genre; Member has
MemberID, Name, Contact Info.
Relationships:
o A Book can have a One-to-Many relationship with Author (a book
can have multiple authors, and an author can write multiple
books).
o Loan represents a relationship between Book and Member, where
each loan instance shows which book was borrowed by which
member.