Unit 2
Unit 2
4 SURESH DELHI 18
Important Terminologies
Attribute: Attributes are the properties that define an entity.
e.g.; ROLL_NO, NAME, ADDRESS
Relation Schema: A relation schema defines the structure of the
relation and represents the name of the relation with its
attributes. e.g.; STUDENT (ROLL_NO, NAME, ADDRESS, PHONE,
and AGE) is the relation schema for STUDENT. If a schema has
more than 1 relation, it is called Relational Schema.
Tuple: Each row in the relation is known as a tuple. The above
relation contains 4 tuples, one of which is shown as:
1 RAM DELHI 9455123451 18
4
NULL Values: The value which is not known or unavailable is
called a NULL value. It is represented by blank space. e.g.; PHONE
of STUDENT having ROLL_NO 4 is NULL.
Relation Key: These are basically the keys that are used to
identify the rows uniquely or also help in identifying tables. These
are of the following types.
o Primary Key
o Candidate Key
o Super Key
o Foreign Key
o Alternate Key
o Composite Key
Constraints in Relational Model
While designing the Relational Model, we define some conditions
which must hold for data present in the database are called
Constraints. These constraints are checked before performing any
operation (insertion, deletion, and updation ) in the database. If
there is a violation of any of the constraints, the operation will fail.
Domain Constraints
These are attribute-level constraints. An attribute can only take
values that lie inside the domain range. e.g.; If a constraint AGE>0
is applied to STUDENT relation, inserting a negative value of AGE
will result in failure.
Key Integrity
Every relation in the database should have at least one set of
attributes that defines a tuple uniquely. Those set of attributes is
called keys. e.g.; ROLL_NO in STUDENT is key. No two students can
have the same roll number. So a key has two properties:
It should be unique for all tuples.
It can’t have NULL values.
Referential Integrity
When one attribute of a relation can only take values from another
attribute of the same relation or any other relation, it is
called referential integrity. Let us suppose we have 2 relations
Table Student
ROLL_NO NAME ADDRESS PHONE AGE BRANCH_CODE
4 SURESH DELHI 18 IT
Table Branch
BRANCH_CODE BRANCH_NAME
CS COMPUTER SCIENCE
IT INFORMATION TECHNOLOGY
ELECTRONICS AND
ECE
COMMUNICATION ENGINEERING
CV CIVIL ENGINEERING
Introduction of ER Model
Peter Chen developed the ER diagram in 1976. The ER model was
created to provide a simple and understandable model for
representing the structure and logic of databases. It has since
evolved into variations such as the Enhanced ER Model and the
Object Relationship Model
The Entity Relational Model is a model for identifying entities to be
represented in the database and representation of how those
entities are related. The ER data model specifies enterprise schema
that represents the overall logical structure of a database
graphically.
The Entity Relationship Diagram explains the relationship among the
entities present in the database. ER models are used to model real-
world objects like a person, a car, or a company and the relation
between these real-world objects. In short, the ER Diagram is the
structural format of the database.
Why Use ER Diagrams In DBMS?
ER diagrams represent the E-R model in a database, making them
easy to convert into relations (tables).
ER diagrams provide the purpose of real-world modeling of
objects which makes them intently useful.
ER diagrams require no technical knowledge and no hardware
support.
These diagrams are very easy to understand and easy to create
even for a naive user.
It gives a standard solution for visualizing the data logically.
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:
Rectangles: Rectangles represent Entities in the ER Model.
Ellipses: Ellipses represent Attributes in the ER Model.
Diamond: Diamonds represent Relationships among Entities.
Lines: Lines represent attributes to entities and entity sets with
other relationship types.
Double Ellipse: Double Ellipses represent Multi-Valued
Attributes.
Double Rectangle: Double Rectangle represents a Weak Entity.
Components of ER Diagram
ER Model consists of Entities, Attributes, and Relationships among
Entities in a Database System.
What is Entity?
An Entity may be an object with a physical existence – a particular
person, car, house, or employee – or it may be an object with a
conceptual existence – a company, a job, or a university course.
What is Entity Set?
An Entity is an object of Entity Type and a set of all entities is called
an entity set. For Example, E1 is an entity having Entity Type
Student and the set of all students is called Entity Set. In ER
diagram, Entity Type is represented as:
Entity Set
What is 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. In ER diagram, the
attribute is represented by an oval.
Attribute
Types of Attributes
1. Key Attribute
The attribute which uniquely identifies each entity in the entity
set is called the key attribute. For example, Roll_No will be unique
for each student. In ER diagram, the key attribute is represented by
an oval with underlying lines.
Key Attribute
2. Composite Attribute
An attribute composed of many other attributes is called a
composite attribute. For example, the Address attribute of the
student Entity type consists of Street, City, State, and Country. In ER
diagram, the composite attribute is represented by an oval
comprising of ovals.
Composite Attribute
3. Multivalued Attribute
An attribute consisting of more than one value for a given entity. For
example, Phone_No (can be more than one for a given student). In
ER diagram, a multivalued attribute is represented by a double
oval.
Multivalued Attribute
4. Derived Attribute
An attribute that can be derived from other attributes of the entity
type is known as a derived attribute. e.g.; Age (can be derived from
DOB). In ER diagram, the derived attribute is represented by a
dashed oval.
Derived Attribute
Entity-Relationship Set
Unary Relationship
Binary Relationship
3. Ternary Relationship: When there are three entity sets
participating in a relationship, the relationship is called a ternary
relationship.
4. N-ary Relationship: When there are n entities set participating
in a relationship, the relationship is called an n-ary relationship.
What is Cardinality?
The number of times an entity of an entity set participates in a
relationship set is known as cardinality. Cardinality can be of
different types:
1. One-to-One: When each entity in each entity set can take part
only once in the relationship, the cardinality is one-to-one. Let us
assume that a male can marry one female and a female can marry
one male. So the relationship will be one-to-one.
the total number of tables that can be used in this is 2.
3. Many-to-One: When entities in one entity set can take part only
once in the relationship set and entities in other entity sets can take
part more than once in the relationship set, cardinality is many to
one. Let us assume that a student can take only one course but one
course can be taken by many students. So the cardinality will be n
to 1. It means that for one course there can be n students but for
one student, there will be only one course.
The total number of tables that can be used in this is 3.
In this case, each student is taking only 1 course but 1 course has
been taken by many students.
4. Many-to-Many: When entities in all entity sets can take part
more than once in the relationship cardinality is many to many. Let
us assume that a student can take more than one course and one
course can be taken by many students. So the relationship will be
many to many.
the total number of tables that can be used in this is 3.
Entity in DBMS
Database management systems (DBMS) are large, integrated
collections of data. They play an important role in modern data
management, helping agencies keep, retrieve, and manage data
effectively. At the core of any DBMS is the concept of entities, which
is a basic concept that refers to real-world devices or ideas inside a
database. This article will explore the sector of entities within a
DBMS, providing an in-depth understanding of this fundamental
concept and its significance in database format.
Entity
An entity is a “thing” or “object” in the real world. An entity
contains attributes, which describe that entity. So anything about
which we store information is called an entity. Entities are recorded
in the database and must be distinguishable, i.e., easily recognized
from the group.
For example: A student, An employee, or bank a/c, etc. all are
entities.
Entity
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.
Key Terminologies used in Entity Set:
Attributes: Attributes are the houses or traits of an entity. They
describe the data that may be connected with an entity.
Entity Type: A category or class of entities that share the same
attributes is referred to as an entity kind.
Entity Instance: An entity example is a particular incidence or
character entity within an entity type. Each entity instance has a
unique identity, often known as the number one key.
Primary Key: A primary key is a unique identifier for every entity
instance inside an entity kind.
It can be classified into two types:
Strong Entity Set
Strong entity sets exist independently and each instance of a strong
entity set has a unique primary key.
Example of Strong Entity includes:
Car Registration Number
Model
Name etc.
Strong Entity
Weak Entity
Kinds of Entities
There are two types of Entities:
Tangible Entity
A tangible entity is a physical object or a physical thing that can
be physically touched, seen or measured.
It has a physical existence or can be seen directly.
Examples of tangible entities are physical goods or physical
products (for example, “inventory items” in an inventory
database) or people (for example, customers or employees).
Intangible Entity
Intangible entities are abstract or conceptual objects that are not
physically present but have meaning in the database.
They are typically defined by attributes or properties that are not
directly visible.
Examples of intangible entities include concepts or categories
(such as “Product Categories” or “Service Types”) and events or
occurrences (such as appointments or transactions).
Entity Types in DBMS
Strong Entity Types: These are entities that exist
independently and have a completely unique identifier.
Weak Entity Types: These entities depend on another entity for
his or her lifestyles and do now not have a completely unique
identifier on their own.
The Example of Strong and Weak Entity Types in DMBS is:
Example