Entity-Relationship (ER) Model
The Entity-Relationship (ER) Model is a way to visually
represent how data is structured and related in a database. It
helps in designing databases by showing how different pieces
of information (data) are connected. The ER model uses a
diagrammatic approach to represent entities, their attributes,
and relationships between them.
Symbols Used in ER Model
ER Model is used to model the logical view of the system
from a data perspective which consists of these symbols:
Components of ER Diagram
ER Model consists of Entities, Attributes, and Relationships
among Entities in a Database System.
Entity:
An entity is any object, thing, or concept about which data is
stored. Example: A student can be an entity.
Entity Set: a set of the same type of entities. Entity sets can
be broadly classified into:
1. Strong entity. 2. Weak entity.
Strong Entity:
Strong entity is one whose existence does not depend on
other entity. Represented by a rectangle.
Weak Entity:
Weak entity is one whose existence depends on other entity.
Represented by a double rectangle.
What is Attributes?
Attributes are the properties that define the entity type. For
example, Roll_No, Name, DOB etc.
Types of Attributes:
● Simple Attributes - Simple attributes are those attributes
which cannot be divided further. Ex. Age
● Composite Attributes - Composite attributes are those
attributes which are composed of many other simple
attributes. Ex. Name, Address etc
● Multi Valued Attributes -those attributes which can take
more than one value for a given entity from an entity set.
Ex. Mobile No, Email ID
● Derived Attributes -those attributes which can be derived
from other attribute(s). Ex. Age can be derived from DOB.
● Key Attributes- those attributes which can identify an
entity uniquely in an entity set. Ex. Roll No.
Relationship:
A relationship shows how entities are related to each other.
Relationships can be of various types depending on how
many entities are involved.
One-to-One (1:1): One instance of an entity is related
to one instance of another entity (e.g., One person has
one passport).
One-to-Many (1:N): One instance of an entity is related
to many instances of another entity (e.g., A teacher can
teach many students).
Many-to-Many (M:N): Many instances of one entity are
related to many instances of another entity (e.g.,
Students enroll in multiple courses, and each course
has multiple students).
Advantages of the ER Model
Simple and Easy to Understand: provides a clear and
easy way to visualize data and its relationships.
Helps in Database Design: It helps designers in creating
a structure for storing data.
Clear Communication: easy way to communicate the
structure of a database between designers, developers,
and users.
Limitations of the ER Model
No Detailed Process Representation:only shows data
and relationships, not the processes or operations on
the data (like how to search or update).
Can Be Complex for Large Systems: For big databases
with many entities and relationships, the ER diagram
can become large and hard to manage.
Relational Model
The Relational Model is a method of structuring data
using tables, where each table is called a relation. The
data in these tables is represented by rows (also called
tuples) and columns (called attributes). Each row in a
table represents a single record, and each column
contains a specific type of information about the records.
The relational model makes it easy to query, insert,
update, and delete data from tables. It's based on
mathematical set theory, where operations like union,
intersection, and difference are used to manage data.
Important Terminologies
NULL Values: The value which is not known
or unavailable is called a NULL value.
Relation Key: These are basically the keys
that are used to identify the rows uniquely.
These are of the following types.
Primary Key
Candidate Key
Super Key
Foreign Key
Alternate Key
Composite Key
Operations in the Relational Model
The relational model allows several operations to
manipulate and query data. These operations
are based on relational algebra. Common
operations include:
Select (σ):
Project (π): The project operation selects
specific columns from a table.
Join: The join operation combines rows from
two or more tables based on a related
column
Union (∪): combines the results of two
queries, removing duplicates. Both queries
must have the same structure (i.e., the same
attributes).
Difference (-): The difference operation
returns rows that are in one table but not in
another.
Intersection (∩): The intersection operation
returns rows that are common to both
tables.
Constraints:
Relational constraints are the restrictions
imposed on the database contents and
operations. They ensure the correctness of
data in the database.
● Domain Constraint - Domain constraint
defines the domain or set of values for an
attribute. It specifies that the value taken by
the attribute must be the atomic value from
its domain.
● Key Constraint - All the values of the
primary key must be unique. The value of
the primary key must not be null.
● Entity Integrity Constraint - Entity integrity
constraint specifies that no attribute of
primary key must contain a null value in any
relation.
● Referential Integrity Constraint - It
specifies that all the values taken by the
foreign key.
Advantages of the Relational Model
Simplicity: The model is simple to
understand and work. This makes it easy to
visualize and manage data.
Flexibility: It allows complex queries to be
written using SQL which is a powerful
language for querying and manipulating
data.
Data Integrity: The use of primary keys
and foreign keys ensures that data remains
accurate and consistent across tables,
reducing data redundancy and maintaining
relationships between tables.
Scalability: Relational databases can
handle large datasets and are highly
scalable, meaning they can grow as data
increases without affecting performance too
much.
Example of Relational Model
Consider a School Database with the
following tables:
1.Students Table:
o Columns: Student_ID (Primary Key),
Name, Age, Gender.
2.Courses Table:
o Columns: Course_ID (Primary Key),
Course_Name, Teacher.
3.Enrollments Table:
o Columns: Enrollment_ID (Primary Key),
Student_ID (Foreign Key), Course_ID
(Foreign Key).
The Students table holds information about
students, the Courses table stores course
details, and the Enrollments table tracks
which students are enrolled in which
courses. The Enrollments table contains
foreign keys linking to the Students and
Courses tables, establishing relationships
between them.
Network Model
The Network Model is based on the concept of
graphs, where entities (or records) are
represented as nodes, and relationships
between entities are represented as edges or
links. Unlike the Hierarchical Model, where
data is organized in a tree-like structure with one
parent for each child, the Network Model
allows multiple parent-child relationships,
forming a more flexible structure.
In the Network Model, a record can have many
related records, and these records are
connected through pointers. It uses a graph
structure to represent these relationships,
allowing for more complex and dynamic
connections between data.
`
Structure of a Network Model
The Network Model uses a graph structure,
which consists of:
Nodes (Records): These represent the
entities or data in the database. Each node
stores information about an entity, like a
record in a table.
Edges (Links/Associations): These
represent relationships between entities. A
single edge can connect one record to one or
more other records, allowing many-to-
many relationships.
Set Structure: The relationships in the
Network Model are organized using a set
structure. A set is a group of nodes and
links that define a relationship. Each set
consists of:
o A parent record.
o One or more child records.
o A link between the parent and child.
Pointers: The edges are implemented using
pointers, which are references or addresses
that connect one record to another.
Operations on Network Model
Insertion: Adding new records and
establishing owner-member relationships.
Deletion: Removing records and
maintaining data integrity by handling
related records and relationships.
Update: Modifying existing records and
relationships between records.
Traversal: Navigating through the network
structure to access related records using
predefined paths.
Search: Retrieving specific records based on
criteria by navigating the network structure.
Features of Network Model
Data Relationship Representation: The
network model uses a graph structure to
represent data relationships. It allows many-
to-many relationships, providing greater
flexibility in how data is connected.
Records and Sets: Data in a network
model is organized into records and sets.
Records are similar to rows in a relational
table, and sets are used to define
relationships between record.
Owner-Member Relationships: The
network model defines data relationships
using owner-member pairs. An owner record
can be linked to multiple member records.
Navigational Access: The network model
supports navigational data access, where
records are accessed through predefined
paths.
Advantages of Network Model
This model is very simple and easy to design
like the hierarchical data model.
This model is capable of handling multiple
types of relationship.
Like a hierarchical model, this model also
does not have any database standard,
This model allows to represent multi parent
relationships.
Disadvantages of Network Model
The schema or the structure of this database
is very complex in nature as all the records
are maintained by the use of pointers.
The design or the structure of this model is
not user-friendly.
This model does not have any scope of
automated query optimization.
This model fails in achieving structural
independence.