DBMS unit 1
DBMS unit 1
UNIT -1
Entity Relationship model: Overview of Data Design Entities,
Attributes and Entity Sets, Relationship and Relationship Sets.
Features of the ER Model- Key Constraints, Participation
Constraints, Weak Entities, Class Hierarchies, Aggregation,
Conceptual Data Base, and Design with ER Model- Entity v/s
Attribute, Entity vs Relationship Binary vs Ternary Relationship and
Aggregation v/s ternary Relationship Conceptual Design for a
Large Enterprise.
The Entity Relationship (E-R) Model
• ER model stands for an Entity-Relationship model. It is a high-level data
model.
• The Entity Relationship model was proposed by Peter Chen in 1976.
• ER model is a diagrammatic representation of logical structure of database.
E-R model describes relationship among entities and attributes.
• Entity Relationship Diagrams (ERD) are the best tools to communicate within
the entire system. These diagrams are the graphical representation of the
flow of data and information.
• This conceptual database model is an effective way of communicating with
the individuals at all the levels.
• The most common use of this diagram is to present the relation of the
various tables present in a database.
Entity- Relationship Diagram (ERD)
An Entity-Relationship (ER) Diagram is a visual representation of the
entities, attributes, and relationships within a system. It is used to model
the structure of a database and is an essential part of the conceptual
design phase of database development.
Entity Set
• An entity set is a collection of similar types of entities that share
the same attributes.
• For example: All students of a school are a entity set
of Student entities.
Types of Entities
Types of Entity
There are two types of entity:
1. Strong Entity
• A Strong Entity is a type of entity that has a key
Attribute. Strong Entity does not depend on other
Entity in the Schema. It has a primary key, that
helps in identifying it uniquely. These are called
Strong Entity Types.
• Strong entities are represented by a single
rectangle. The relationship of two strong entities is
represented by a single diamond.
• Strong Entity Type: Strong entity are those entity types
which has a key attribute. The primary key helps in
identifying each entity uniquely
• In the example, Roll_no identifies each element of the table
uniquely and hence, we can say that STUDENT is a strong
entity type.
2. Weak Entity
An Entity type has a key attribute that uniquely identifies each entity in the entity
set. But some entity type exists for which key attributes can’t be defined. Weak
entity type can't be identified on its own. These are called Weak Entity types .
• Example : If we have two tables of Customer(Customer_id, Name, Mobile_no, Age, Gender)
and Address(Locality, Town, State, Customer_id). Here we cannot identify the address
uniquely as there can be many customers from the same locality. So, for this, we need an
attribute of Strong Entity Type i.e ‘Customer’ here to uniquely identify entities of 'Address'
Entity Type.
Attributes
• Attributes are the properties that define the
entity type. For example, Roll_No, Name, DOB,
Age, Address, and Mobile_No are the attributes
that define entity type Student.
Types of Attributes
There are different types of attributes as discussed
below-
• Simple Attribute
• Composite Attribute
• Single-Valued Attribute
• Multi-Valued Attribute
• Stored Attribute
• Derived Attribute
• Null Attribute
• Key Attribute
1. Simple Attribute
• An attribute that cannot be further subdivided into
components is a simple attribute.
Example: The roll number of a student, the ID
number of an employee, gender, and many more.
2.Composite Attribute
• An attribute that can be split into components is
a composite attribute.
• Example: The address can be further split into
house number, street number, city, state,
country, and pin code, the name can also be split
into first name middle name, and last name.
3. Single-Valued Attribute
• The attribute which takes up only a single value
for each entity instance is a single-valued
attribute.
• Example: Name, DOB.
4. Multi-Valued Attribute
• The attribute which takes up more than a single value
for each entity instance is a multi-valued
attribute. And it is represented by double oval shape.
Example: Phone number of a student: Landline and
mobile.
•
5. Stored Attribute
• The stored attribute are those attribute which doesn’t require any type of
further update since they are stored in the database.
• These attributes are used to store permanent information about an entity
which will remain constant throughout the lifetime of the entity.
Example:
•In an employee database: If a table stores employee information like first name,
last name, and middle name, the "middle name" attribute could be considered "null"
for an employee who does not have a middle name.
8. Key Attribute
• The attribute which has unique values for every row in the
table is known as a Key Attribute. The key attribute has a
very crucial role in the database.
Null May or may not have a value Middle Name, Spouse Name
Relationships
• In a Database Management System (DBMS),
relationships define how data in one table is related
to data in another.
• Understanding these relationships is essential for
designing an efficient database structure.
• A relationship in DBMS refers to the logical
association between different entities (such as
customers, products, or orders) that are stored in
separate tables. These associations allow databases
to organize and retrieve related information
efficiently.
Degree of Relationship
The number of entity types which took part in the
entity relationship is called the degree of relationships.
Types of degree
Based on the number of linked entity types, we have 4
types of degrees of relationships.
1. Unary
2. Binary
3. Ternary
4. N-ary
Unary Relationship (Degree 1)
• In this type of relationship, both the associating entity types are the
same. So unary relationships exist when both entity types are the
same and we call them the degree of relationship is 1.
• In other words, in a relation only one entity set is participating then
such type of relationship is known as a unary relationship.
Binary relationship
• A binary relationship exists when exactly two entity type
participates. When such a relationship is present we say that
the degree is 2. This is the most common degree of
relationship. It is easy to deal with such relationship as these
can be easily converted into relational tables.
• For example, We have two entity type ‘Customer’ and ‘Account’ where each
‘Customer’ has an ‘Account’ which stores the account details of the
‘Customer’. Since we have two entity types participating we call it a binary
relationship. Also, one ‘Customer’ can have many ‘Account’ but each
‘Account’ should belong to only one ‘Customer’. We can say that it is a one-
to-many binary relationship.
Ternary relationship (degree 3)
• A ternary relationship exists when exactly three entity type
participates. When such a relationship is present we say that the
degree is 3. As the number of entity increases in the relationship,
it becomes complex to convert them into relational tables.
N-ary relationship
• An N-ary relationship exists when ‘n’ number of entities are
participating. So, any number of entities can participate in a
relationship. There is no limitation to the maximum number of
entities that can participate. But, relations with a higher degree are
not common. This is because the conversion of higher degree
relations to relational tables gets complex.
Mapping Cardinality
Mapping cardinalities, or cardinality ratios, express the
number of entities to which another entity can be associated via a
relationship set. Mapping cardinalities are most useful in describing
binary relationship sets.
In a Database Management System (DBMS), mapping cardinalities
explains how entities (tables) in a database schema relate to one
another.
They provide the number of instances of one entity that can be linked
to the number of instances of another entity via a certain kind of
relationship, such as many-to-many, one-to-one, one-to-many, or one-
to-many.
For a binary relationship set R between entity sets A and B, the mapping cardinality
must be one of the following:
1. One-to-one. An entity in A is associated with at most one entity in B, and an entity in B
is associated with at most one entity in A.
Entities: Person & Passport
Relation: A person can have only one passport, and each passport belongs to only
one person.
2. One-to-many. An entity in A is associated with any number (zero or more) of entities in
B. An entity in B, however, can be associated with at most one entity in A.
Entities: Manager & Employee
Relation: A Manager can manage many employees, but a employee is assigned to
only one manager.
3. Many-to-one. An entity in A is associated with at most one entity in B. An
entity in B, however, can be associated with any number (zero or more) of
entities in A.
Entities: Faculty and Department
Relation: Many faculty can be part of one department while one
department can have multiple faculty.
4. Many-to-many. An entity in A is associated with any number (zero or
more) of entities in B, and an entity in B is associated with any number (zero
or more) of entities in A.
Entities: Student and Course
Relation: Many students can participate in many courses while many courses
can be participated by many students.
Chen notation for ERD
• Chen Notation is a graphical representation used
in Entity-Relationship (ER) Diagrams,
introduced by Peter Chen in 1976.
• It is primarily used for conceptual database
design, providing a clear and detailed structure of
entities, attributes, and relationships.
Questions on cardinality
What would be the cardinality between:
a) A student and an ID card in a university?
1.Generalization
2.Specialization
3.Aggregation
1. Generalization
• Generalization is the process of extracting common
properties from a set of entities and create a generalized
entity from it.
• Generalization is a "bottom-up approach" in which two or
more entities can be combined to form a higher level
entity if they have some attributes in common.
• Subclasses are combined to make a superclass.
• Generalization is used to emphasize the similarities
among lower-level entity set and to hide differences in
the schema.
• Depicted by triangle component labeled ISA
• In the given diagram, the Person entity acts as the generalized superclass,
containing common attributes such as Name, Phone, and Address. The
Employee and Customer entities are its subclasses, inheriting these attributes
while also having their own unique attributes. Employee has Employee_id and
Salary, whereas Customer has Customer_id, Credit, and Email.
• The ISA relationship in the diagram signifies inheritance, ensuring that every
Employee or Customer is also a Person. This hierarchical structure helps in data
abstraction, enabling better organization and minimizing duplication.
2. Specialization
• Specialization is opposite of Generalization.
• In Specialization, an entity is broken down into sub-entities
based on their characteristics.
• Specialization is a "Top-down approach" where higher level
entity is specialized into two or more lower level entities.
• Specialization is used to identify the subset of an entity set
that shares some distinguishing characteristics
• Specialization can be repeatedly applied to refine the design
of schema.
• Normally, the superclass is defined first, the subclass and its
related attributes are defined next, and relationship set are
then added.
• Depicted by triangle component labeled ISA
In the given image, the Vehicle entity is the superclass, representing a general
category.
It is specialized into three subclasses: Car, Bus, and Motorcycle. The ISA
triangle denotes an inheritance relationship, meaning all subclasses inherit
the common properties of the superclass while also having their own unique
attributes.
Specialization Example
3. Aggregation
• Aggregation in DBMS is a higher-level abstraction that
treats a relationship as an entity to participate in
another relationship. It is used when a relationship
itself needs to be connected with another entity,
avoiding redundancy and improving database
modeling.
• Key Features:
• Allows relationships to act as entities in new
relationships.
• Helps represent complex real-world scenarios
efficiently.
• Prevents unnecessary redundancy in ER diagrams.
• Example:
• Consider a ternary
relationship works_on between Employee, Branch and Job.
• An Employee works on a particular job at a particular branch.
2.UNIQUE: Ensures that all values in a specified column are distinct from
each other.
5.PRIMARY KEY: A combination of NOT NULL and UNIQUE, ensuring each row
in a table is uniquely identified.