0% found this document useful (0 votes)
25 views69 pages

DBMS 2-Entity Relationship Model

A database schema defines the structure and organization of a database. It includes entity definitions and relationships, as well as constraints. A schema is logical and does not contain data itself. It defines the skeleton of the database that actual database instances will conform to. A schema can be divided into physical and logical components, where physical refers to how data is stored and logical refers to constraints on the data.

Uploaded by

Dhiraj Pawar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views69 pages

DBMS 2-Entity Relationship Model

A database schema defines the structure and organization of a database. It includes entity definitions and relationships, as well as constraints. A schema is logical and does not contain data itself. It defines the skeleton of the database that actual database instances will conform to. A schema can be divided into physical and logical components, where physical refers to how data is stored and logical refers to constraints on the data.

Uploaded by

Dhiraj Pawar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 69

DATABASE

MANAGEMENT
SYSTEM
DBMS - DATA SCHEMAS
DataBase Schema:
A database schema is the skeleton structure
that represents the logical view of the entire
database.
It defines how the data is organized and
how the relations among them are
associated.
DBMS - DATA SCHEMAS
DataBase Schema:
It formulates all the constraints that are to
be applied on the data.
A database schema defines its entities and
the relationship among them.
It contains a descriptive detail of the
database, which can be depicted by means
of schema diagrams.
DBMS - DATA SCHEMAS
DataBase Schema:
It’s the database designers who design the
schema to help programmers understand
the database and make it useful.
DBMS - DATA SCHEMAS
DataBase Schema:
DBMS - DATA SCHEMAS
DataBase Schema:
A database schema can be divided into two
categories:
Physical Database Schema − This schema
pertains to the actual storage of data and
its form of storage like files, indices, etc.
It defines how the data will be stored in a
secondary storage.
DBMS - DATA SCHEMAS
DataBase Schema:
A database schema can be divided into two
categories:
Logical Database Schema − This schema
defines all the logical constraints that need
to be applied on the data stored.
It defines tables, views, and integrity
constraints.
DBMS - DATA SCHEMAS
DataBase Instance:
It is important that we distinguish these two
terms individually.
Database schema is the skeleton of
database.
It is designed when the database doesn't
exist at all.
DBMS - DATA SCHEMAS
DataBase Instance:
Once the database is operational, it is very
difficult to make any changes to it.
A database schema does not contain any
data or information.
DBMS - DATA SCHEMAS
DataBase Instance:
A database instance is a state of
operational database with data at any
given time.
It contains a snapshot of the database.
Database instances tend to change with
time.
DBMS - DATA SCHEMAS
DataBase Instance:
A database instance is a state of
operational database with data at any
given time.
It contains a snapshot of the database.
Database instances tend to change with
time.
DBMS - DATA SCHEMAS
DataBase Instance:
A DBMS ensures that its every instance
(state) is in a valid state, by diligently
following all the validations, constraints,
and conditions that the database designers
have imposed.
DBMS - DATA INDEPENDENCE:

If a database system is not multi-layered,


then it becomes difficult to make any
changes in the database system.
Database systems are designed in multi-
layers .
DBMS - DATA INDEPENDENCE:

A database system normally contains a lot


of data in addition to users’ data.
For example , it stores data about data ,
known as metadata , to locate and retrieve
data easily.
DBMS - DATA INDEPENDENCE:

It is rather difficult to modify or update a set


of metadata once it is stored in the
database.
But as a DBMS expands, it needs to change
over time to satisfy the requirements of the
users.
If the entire data is dependent, it would
become a tedious and highly complex job.
DBMS - DATA INDEPENDENCE:
DBMS - DATA INDEPENDENCE:

Metadata itself follows a layered


architecture , so that when we change the
data at one layer , it does not affect the
data at another level.
This data is independent but mapped to each
other.
ogical Data Independence:

Logical data is data about database, that is, it stores


information about how data is managed inside.
For example, a table (relation) stored in the database
and all its constraints, applied on that relation.

Logical data independence is a kind of mechanism,


which liberalizes itself from actual data stored on the
disk.
If we do some changes on table format, it should not
change the data residing on the disk.
Physical Data Independence:

All the schemas are logical, and the actual data is


stored in bit format on the disk.
Physical data independence is the power to
change the physical data without impacting the
schema or logical data.
For example, in case we want to change or
upgrade the storage system itself − suppose we
want to replace hard-disks with SSD − it should
not have any impact on the logical data or
schemas.
ER Model - Basic Concepts:

The ER model defines the conceptual view of a


database.
It works around real-world entities and the
associations among them.
At view level, the ER model is considered a good
option for designing databases.
ER Model - Basic Concepts:

Entity:
An entity can be a real-world object, either
animate or inanimate, that can be easily
identifiable.
For example, in a school database, students,
teachers, classes, and courses offered can be
considered as entities.
All these entities have some attributes or
properties that give them their identity.
ER Model - Basic Concepts:

Entity:
An entity set is a collection of similar types of
entities.
An entity set may contain entities with attribute
sharing similar values.
For example, a Students set may contain all the
students of a school; likewise a Teachers set may
contain all the teachers of a school from all
faculties.
Entity sets need not be disjoint.
ER Model - Basic Concepts:

Attributes:
Entities are represented by means of their
properties, called attributes.
All attributes have values.
For example, a student entity may have name,
class, and age as attributes.
There exists a domain or range of values that can
be assigned to attributes.
ER Model - Basic Concepts:

Attributes:

For example, a student's name cannot be a


numeric value.
It has to be alphabetic.
A student's age cannot be negative, etc.
ER Model - Basic Concepts:

Types Of Attributes:
Simple attribute −
Simple attributes are atomic values, which cannot be
divided further.
For example, a student's phone number is an atomic
value of 10 digits.

Composite attribute −
Composite attributes are made of more than one
simple attribute.
For example, a student's complete name may have
first_name and last_name.
ER Model - Basic Concepts:

Types Of Attributes:

Derived attribute −
Derived attributes are the attributes that do not exist
in the physical database, but their values are derived
from other attributes present in the database.
For example, average_salary in a department should
not be saved directly in the database, instead it can
be derived.
For another example, age can be derived from
data_of_birth.
ER Model - Basic Concepts:

Types Of Attributes:

Single-value attribute −
Single-value attributes contain single value.
For example − Social_Security_Number.

Multi-value attribute −
Multi-value attributes may contain more than one
values.
For example, a person can have more than one
phone number, email_address, etc.
ER Model - Basic Concepts:

Types Of Attributes:

These attribute types can come together in a


way like:
simple single-valued attributes
simple multi-valued attributes
composite single-valued attributes
composite multi-valued attributes
ER Model - Basic Concepts:

Entity-Set and Keys


Key is an attribute or collection of attributes that uniquely
identifies an entity among entity set.
For example, the roll_number of a student makes him/her
identifiable among students.

Super Key − A set of attributes (one or more) that


collectively identifies an entity in an entity set.

Candidate Key − A minimal super key is called a


candidate key.
An entity set may have more than one candidate key.
ER Model - Basic Concepts:

Entity-Set and Keys

Primary Key −
A primary key is one of the candidate keys chosen by the
database designer to uniquely identify the entity set.
ER Model - Basic Concepts:

Relationship:
The association among entities is called a relationship.
For example, an employee works_at a department, a
student enrolls in a course.
Here, Works_at and Enrolls are called relationships.

Relationship Set
A set of relationships of similar type is called a
relationship set.
Like entities, a relationship too can have attributes.
These attributes are called descriptive attributes.
ER Model - Basic Concepts:

Degree of Relationship:

The number of participating entities in a relationship


defines the degree of the relationship.
Binary = degree 2
Ternary = degree 3
n-ary = degree
ER Model - Basic Concepts:

Mapping Cardinalities:
Cardinality defines the number of entities in one entity
set, which can be associated with the number of entities
of other set via relationship set.

One-to-one −
One entity from entity set A can be associated with at
most one entity of entity set B and vice versa.
ER Model - Basic Concepts:

One-to-one −
One entity from entity set A can be associated with at
most one entity of entity set B and vice versa.
ER Model - Basic Concepts:

One-to-many :
One entity from entity set A can be associated with more
than one entities of entity set B however an entity from
entity set B, can be associated with at most one entity.
ER Model - Basic Concepts:

Many-to-one:
More than one entities from entity set A can be
associated with at most one entity of entity set B,
however an entity from entity set B can be associated
with more than one entity from entity set A.
ER Model - Basic Concepts:

Many-to-many:
One entity from A can be associated with more than one
entity from B and vice versa.
ER Diagram Representation:

What is ER Diagram?
Any object, for example, entities, attributes of an entity,
relationship sets, and attributes of relationship sets, can be
represented with the help of an ER diagram.

Entity:
Entities are represented by means of rectangles.
Rectangles are named with the entity set they represent.
ER Diagram Representation:

Attributes:
Attributes are the properties of entities.
Attributes are represented by means of ellipses.
Every ellipse represents one attribute and is directly
connected to its entity (rectangle).
ER Diagram Representation:

Attributes:

If the attributes are composite, they are further divided in a


tree like structure.
Every node is then connected to its attribute.
That is, composite attributes are represented by ellipses
that are connected with an ellipse.
ER Diagram Representation:

Attributes:
ER Diagram Representation:

Attributes:

Multivalued attributes are depicted by double ellipse.


ER Diagram Representation:

Attributes:

Multivalued attributes are depicted by double ellipse.


ER Diagram Representation:

Attributes:

Derived attributes are depicted by dashed ellipse.


ER Diagram Representation:

Relationship:

Relationships are represented by diamond-shaped box.


Name of the relationship are written inside the diamond -
box.
All the entities(rectangles) participating in a relationship ,
are connected to it by a line.
ER Diagram Representation:

Relationship:

Binary Relationship and Cardinality


A relationship where two entities are participating is called
a binary relationship.
Cardinality is the number of instance of an entity from a
relation that can be associated with the relation.
ER Diagram Representation:

Relationship:

One-to-one −
When only one instance of an entity is associated with the
relationship, it is marked as '1:1'.
The following image reflects that only one instance of each
entity should be associated with the relationship.
It depicts one-to-one relationship.
ER Diagram Representation:

Relationship:

One-to-one −
ER Diagram Representation:

Relationship:

One-to-many −
When more than one instance of an entity is associated
with a relationship, it is marked as '1:N'.
The following image reflects that only one instance of
entity on the left and more than one instance of an entity
on the right can be associated with the relationship.
It depicts one-to-many relationship.
ER Diagram Representation:

Relationship:

One-to-many −
ER Diagram Representation:

Relationship:

Many - to - one:
When more than one instance of entity is associated with
the relationship, it is marked as 'N:1'.
The following image reflects that more than one instance
of an entity on the left and only one instance of an entity
on the right can be associated with the relationship.
It depicts many-to-one relationship.
ER Diagram Representation:

Relationship:

Many - to - one:
ER Diagram Representation:

Relationship:

Many - to - Many:

The following image reflects that more than one instance


of an entity on the left and more than one instance of an
entity on the right can be associated with the relationship.
It depicts many-to-many relationship.
ER Diagram Representation:

Relationship:

Many - to - Many:
ER Diagram Representation:

Relationship:

Many - to - Many:

Participation Constraints
Total Participation − Each entity is involved in the
relationship.
Total participation is represented by double lines.

Partial participation −
Not all entities are involved in the relationship.
Partial participation is represented by single lines.
ER Diagram Representation:

Relationship:

Many - to - Many:

Participation Constraints:
Generalization Aggregation:

The ER Model has the power of expressing database


entities in a conceptual hierarchical manner.
As the hierarchy goes up, it generalizes the view of entities,
and as we go deep in the hierarchy, it gives us the detail of
every entity included.

Going up in this structure is called generalization, where


entities are clubbed together to represent a more
generalized view.
For example, a particular student named Mira can be
generalized along with all the students.
The entity shall be a student, and further, the student is a
person.
Generalization Aggregation:

The reverse is called specialization where a person is a


student, and that student is Mira.

Generalization:
As mentioned above, the process of generalizing entities,
where the generalized entities contain the properties of all
the generalized entities, is called generalization.
In generalization, a number of entities are brought together
into one generalized entity based on their similar
characteristics.
For example, pigeon, house sparrow, crow and dove can all
be generalized as Birds.
Generalization
Specialization:

Specialization is the opposite of generalization. In


specialization, a group of entities is divided into sub-
groups based on their characteristics.
Take a group ‘Person’ for example. A person has name,
date of birth, gender, etc.
These properties are common in all persons, human beings.
But in a company, persons can be identified as employee,
employer, customer, or vendor, based on what role they
play in the company.
Specialization:
Specialization:

Similarly, in a school database, persons can be specialized


as teacher, student, or a staff, based on what role they play
in school as entities.
Inheritance:

We use all the above features of ER-Model in order to create


classes of objects in object-oriented programming.
The details of entities are generally hidden from the user; this
process known as abstraction.
Inheritance is an important feature of Generalization and
Specialization.
It allows lower-level entities to inherit the attributes of
higher-level entities.
Inheritance:
Inheritance:

For example, the attributes of a Person class such as name,


age, and gender can be inherited by lower-level entities such
as Student or Teacher.
Inheritance:

For example, the attributes of a Person class such as name,


age, and gender can be inherited by lower-level entities such
as Student or Teacher.
BENEFITS OF INTERNSHIP
30 DAYS OF LIVE SESSIONS
90 DAYS OF ACCESS TO RECORDS
6+ SOURCE CODES DBMS PROJECTS
30 DOWNLOADABLE PRESENTATIONS
5 MENTOR LIVE IN MASTEMIND SESSIONS
INTERNSHIP CONFIRMATION LETTER
INTERNSHIP CERTIFICATION
REG FEE : RS.1999
COUPON : DBMSMC
DISCOUNTED FEE : RS.999
REG LINK - 'HTTPS://IMJO.IN/Y6A9GP

JOIN AS INTERNSHIP USER


@DBMS MASTERCLASS
Thank you
MASTERCLASS CO ORDINATOR - 8925533488

You might also like