0% found this document useful (0 votes)
3 views

Chapter_two_note

The document provides an overview of data models in Database Management Systems (DBMS), focusing on the Entity-Relationship (ER) model, which visually represents data elements and their relationships. It discusses various data models, including Hierarchical, Network, Relational, and Object-Oriented models, highlighting their advantages and disadvantages. Additionally, it explains key components of the ER model, such as entities, attributes, relationships, and cardinality, along with the significance of ER diagrams in database design.

Uploaded by

top1sandesh07
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Chapter_two_note

The document provides an overview of data models in Database Management Systems (DBMS), focusing on the Entity-Relationship (ER) model, which visually represents data elements and their relationships. It discusses various data models, including Hierarchical, Network, Relational, and Object-Oriented models, highlighting their advantages and disadvantages. Additionally, it explains key components of the ER model, such as entities, attributes, relationships, and cardinality, along with the significance of ER diagrams in database design.

Uploaded by

top1sandesh07
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Unit 2.

Data Models

2.1 Introduction to Entity Relationship Model

2.2 Entity type

2.3 Entities set

2.4 Attributes and keys

2.5 Relationship types and sets

2.6 E-R diagrams

Data Models :=>

A Data Model in Database Management System (DBMS) is the concept of tools


that are developed to summarize the description of the database. Data Models
provide us with a transparent picture of data which helps us in creating an actual
database. It shows us from the design of the data to its proper implementation of
data.

It defines the data elements and the relationships between the data elements.
Data Models are used to show how data is stored, connected, accessed and
updated in the database management system. Here, we use a set of symbols and
text to represent the information so that members of the organization can
communicate and understand it. Though there are many data models being used
nowadays but the Relational model is the most widely used model.

A database model shows the logical structure of a database, including the


relationships and constraints that determine how data can be stored and
accessed.

Types of data models in DBMS :=>


1. Hierarchical Model
2. Network Model
3. Entity-Relationship Model
4. Relational Model
5. Object-Oriented Data Model
6. Object-Relational Data Model
7. Flat Data Model
8. Semi-Structured Data Model
9. Associative Data Model
10.Context Data Model

1. Hierarchical Model:=>
Hierarchical Model was the first DBMS model. This model organizes the
data in the hierarchical tree structure. The hierarchy starts from the root
which has root data and then it expands in the form of a tree adding child
node to the parent node.

Example: We can represent the relationship between the shoes present on a


shopping website in the following way:
Advantages of Hierarchical Model

 It is very simple and fast to traverse through a tree-like structure.


 Any change in the parent node is automatically reflected in the child node
so, the integrity of data is maintained.

Disadvantages of Hierarchical Model

 Complex relationships are not supported.


 As it does not support more than one parent of the child node so if we have
some complex relationship where a child node needs to have two parent
node then that can't be represented using this model.
 If a parent node is deleted then the child node is automatically deleted.

2. Network Model:=> This model is an extension of the hierarchical model. It


was the most popular model before the relational model. This model is the
same as the hierarchical model, the only difference is that a record can
have more than one parent. It replaces the hierarchical tree with a graph.
Example: In the example below we can see that node student has two
parents i.e. CSE Department and Library. This was earlier not possible in the
hierarchical model.

Features of a Network Model

 Ability to Merge more Relationships: In this model, as there are more


relationships so data is more related. This model has the ability to manage
one-to-one relationships as well as many-to-many relationships.
 Many paths: As there are more relationships so there can be more than one
path to the same record. This makes data access fast and simple.
 Circular Linked List: The operations on the network model are done with
the help of the circular linked list. The current position is maintained with
the help of a program and this position navigates through the records
according to the relationship.
Advantages of Network Model

 The data can be accessed faster as compared to the hierarchical model.


This is because the data is more related in the network model and there
can be more than one path to reach a particular node. So the data can be
accessed in many ways.
 As there is a parent-child relationship so data integrity is present. Any
change in parent record is reflected in the child record.

Disadvantages of Network Model

 As more and more relationships need to be handled the system might get
complex. So, a user must be having detailed knowledge of the model to
work with the model.
 Any change like updation, deletion, insertion is very complex.

3. Entity Relationship Model:=> Entity-Relationship Model or simply ER


Model is a high-level data model diagram. In this model, we represent the
real-world problem in the pictorial form to make it easy for the
stakeholders to understand. It is also very easy for the developers to
understand the system by just looking at the ER diagram. We use the ER
diagram as a visual tool to represent an ER Model. ER diagram has the
following three components:
a. Entities: Entity is a real-world thing. It can be a person, place, or even a
concept. Example: Teachers, Students, Course, Building, Department,
etc are some of the entities of a School Management System.
b. Attributes: An entity contains a real-world property called attribute. This
is the characteristics of that attribute. Example: The entity teacher has
the property like teacher id, salary, age, etc.
c. Relationship: Relationship tells how two attributes are related. Example:
Teacher works for a department
Example:
In the above diagram, the entities are Teacher and Department. The attributes of
Teacher entity are Teacher_Name, Teacher_id, Age, Salary, Mobile_Number. The
attributes of entity Department entity are Dept_id, Dept_name. The two entities
are connected using the relationship. Here, each teacher works for a department.

4. Relational Model:=>

Relational Model is the most widely used model. In this model, the data is
maintained in the form of a two-dimensional table. All the information is stored in
the form of row and columns. The basic structure of a relational model is tables.
So, the tables are also called relations in the relational model. Example: In

Advnatages of Relational Model

 Simple: This model is more simple as compared to the network and


hierarchical model.
 Scalable: This model can be easily scaled as we can add as many rows and
columns we want.
 Structural Independence: We can make changes in database structure
without changing the way to access the data. When we can make changes
to the database structure without affecting the capability to DBMS to
access the data we can say that structural independence has been
achieved.

Disadvantages of Relational Model

 Hardware Overheads: For hiding the complexities and making things easier
for the user this model requires more powerful hardware computers and
data storage devices.
 Bad Design: As the relational model is very easy to design and use. So the
users don't need to know how the data is stored in order to access it. This
ease of design can lead to the development of a poor database which
would slow down if the database grows.
But all these disadvantages are minor as compared to the advantages of the
relational model. These problems can be avoided with the help of proper
implementation and organisation

5. Object-Oriented Data Model:=>

The real-world problems are more closely represented through the object-
oriented data model. In this model, both the data and relationship are present in
a single structure known as an object. We can store audio, video, images, etc in
the database which was not possible in the relational model(although you can
store audio and video in relational database, it is adviced not to store in the
relational database). In this model, two are more objects are connected through
links. We use this link to relate one object to other objects . This can be
understood by the example given below:

In the above example, we have two objects Employee and Department. All the
data and relationships of each object are contained as a single unit. The attributes
like Name, Job_title of the employee and the methods which will be performed by
that object are stored as a single object. The two objects are connected through a
common attribute i.e the Department_id and the communication between these
two will be done with the help of this common id.

6. Flat Data Model:=>


It is a simple model in which the database is represented as a table
consisting of rows and columns. To access any data, the computer has to
read the entire table. This makes the modes slow and inefficient.

2.1 Introduction to Entity Relationship Model:=>

The Entity-Relationship (ER) Model is a conceptual framework used to


describe and visualize the structure of a database. It is a high-level data
model that defines data elements and their relationships. The ER model is
widely used in database design and helps in creating a detailed blueprint of
the data and its relationships, which can then be translated into a physical
database.

Key Components of the ER Model


Entities:

An entity is an object or thing in the real world that is distinguishable from


other objects. Entities can be physical objects (like a person or a car) or
concepts (like a project or a course).
Each entity is represented by a set of attributes that describe its properties.
For example, an entity "Student" might have attributes like Student_ID,
Name, and Date_of_Birth.
Attributes:

Attributes are the properties or characteristics of an entity. Each attribute


has a value for each entity instance.
Attributes can be of various types, such as:
Simple: Cannot be divided further (e.g., Age).
Composite: Can be divided into smaller sub-parts (e.g., Address can be
divided into Street, City, State).
Derived: Can be derived from other attributes (e.g., Age can be derived
from Date_of_Birth).
Multivalued: Can have multiple values (e.g., Phone_Numbers).
Relationships:

Relationships describe how entities interact with each other. A relationship


is an association among two or more entities.
Relationships can also have attributes, known as descriptive attributes.
The degree of a relationship refers to the number of entities involved
(binary, ternary, etc.).
Cardinality:

Cardinality specifies the number of instances of one entity that can be


associated with instances of another entity.
Common cardinalities include:
 One-to-One (1:1): One instance of an entity is associated with one
instance of another entity.
 One-to-Many (1:M): One instance of an entity is associated with
multiple instances of another entity.
 Many-to-Many (M:N): Multiple instances of one entity are associated
with multiple instances of another entity.
ER Diagrams
ER Diagrams (ERDs) are visual representations of the ER model. They use
symbols to represent entities, attributes, and relationships:

Rectangles represent entities.


Ellipses represent attributes.
Diamonds represent relationships.
Lines connect entities to relationships and attributes to entities.
Benefits of the ER Model:=>
Clarity: Provides a clear and systematic way to visualize data and
relationships.
Design: Helps in designing databases that are well-structured and free of
anomalies.
Documentation: Acts as documentation that can be referred to during the
development and maintenance of the database.
Communication: Serves as a communication tool between stakeholders,
including database designers, developers, and end-users.
Example of an ER Model
Consider a simple ER model for a university database:

Entities: Student, Course, Instructor


Attributes:
Student: Student_ID, Name, Date_of_Birth
Course: Course_ID, Course_Name, Credits
Instructor: Instructor_ID, Name, Department
Relationships:
Enrollment: Connects Student and Course (attributes: Grade)
Teaching: Connects Instructor and Course
Conclusion
The Entity-Relationship Model is a foundational tool in database design. By
focusing on entities, attributes, and relationships, it provides a clear
framework for modeling complex data systems. Understanding and utilizing
the ER model effectively can lead to the creation of efficient and robust
databases that meet organizational need.

2.2. Entities type:=>


Entity :=>A person, organization, object type, or concept about which
information is stored. Describes the type of the information that is being
mastered. An entity type typically corresponds to one or several related
tables in database.
An entity can be of two types :
Tangible Entity : Entities that exist in the real world physically. Example:
Person, car, etc.
Intangible Entity : Entities that exist only logically and have no physical
existence. Example: Bank Account, etc.
Note:=>
An entity is a “thing” that exists and can be uniquely identified, e.g., an
individual person. An entity type (or entity set) is a collection of similar
entities, e.g., a collection of people. An entity type. ▶ is similar to a class in
object-oriented languages. ▶ has associated attributes, which represent
properties.

Entity type:=>

Entity type:=>

a. Strong entity type:=>Entity type having key attribute where key attribute
is a unique identifier of a particular row.

b. Weak entity type:=> Entity type does not have key attribute.
Example:=>

2.4 Attributes and keys:=>

An attribute is a property or characteristic of an entity. An entity may contain any


number of attributes. One of the attributes is considered as the primary key. In an
Entity-Relation model, attributes are represented in an elliptical shape. For
example, in a customer database, the attributes might be name, address, and
phone number. In a product database, the attributes might be name, price, and
date of manufacture.

ERD attributes are characteristics of the entity that help users to better
understand the database. Attributes are included to include details of the various
entities that are highlighted in a conceptual ER diagram.

Example: Student has attributes like name, age, roll number, and many more. To
uniquely identify the student, we use the primary key as a roll number as it is not
repeated. Attributes can also be subdivided into another set of attributes.
Types of attributes :=>

a. Single attributes
b. Composite attributes
c. Single-valued attributes
d. Multi-valued attributes
e. Derived attribute
f. Complex attribute
a. Single attributes:=> 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.
b. 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.
c. Single-valued attribute:=>
The attribute which takes up only a single value for each entity instance is a
single-valued attribute.

Example: The age of a student.


d. Multi-valued attribute:=>
The attribute which takes up more than a single value for each entity
instance is a multi-valued attribute.

Example: Phone number of a student: Landline and mobile.


e. Derived attribute :
An attribute that can be derived from other attributes is derived attributes.

Example: Total and average marks of a student.


f. Null Attribute:
This attribute can take NULL value when entity does not have value for it.

Example:

The ‘Net Banking Active Bin’ attribute gives weather particular customer
having net banking facility activated or not activated.

For bank which does not offer facility of net banking in customer table ‘Net
Banking Active Bin’ attribute is always null till Net banking facility is not
activated as this attribute indicates Bank offers net banking facility or does
not offers.
g. Stored attribute:
The stored attribute are those attribute which doesn’t require any type of
further update since they are stored in the database.

Example: DOB(Date of birth) is the stored attribute.

h. Key attribute:
Key attributes are those attributes that can uniquely identify the entity in
the entity set.

Example: Roll-No is the key attribute because it can uniquely identify the
student.
Types of keys:=>
Key:=>
-> A key is a value which can always be used to uniquely identify any record
or row of data from the table.
-> It is also used to establish and identify relationships between tables.
For example:=> Id is used as a key in the student table because it is unique
for each student.
In the person table, passport_number, License_number are keys since they
are unique for each person.
Types of keys:=>
a. Super key
b. Candidate key
c. Primary key
d. Composite key
e. Foreign key
a. Super key:=>
A super key is a set of one or more attributes that, taken collectively,
allow us to identify uniquely an entity in the entity set.
For example:=> In the student table with attribute
(S_rollno, S_name, S_branch,S_year)
Super key=> S1 -> S_rollno, S_name
S2 -> S_rollno, S_branch
S3 -> S_rollno, S_year
S4 -> S_rollno, S_name, S_branch
S5 -> S_rollno, S-branch, S_year
b. Candidate key :=>
The minimal set of attributes that can uniquely a tuple is known as a
candidate key
Candidate key can be defined as the minimum number of super key
that identifies the record uniquely.
It must contain unique values
Every table must have at least a single candidate key.
For example:=> In student table with attribute (S_rollno,S_name,
S_branch, S_year)
Candidate key=> C1=> S_rollno
C2 => S_rollno, S_name
c. Primary key:=> It can be defined as the minimum number of
candidate key that is chosen by the database designer as the
principal means of identifying entities within an entity set. It is a
unique key. It can identify only one tuple (record) at a time. It has no
duplicate values , it has unique values. It cannot be NULL. Primary
keys are not necessarily to be a single column , more than one the
column can also be a primary key for a table.
For example :=> In student table with attribute(S_rollno, S_name,
S_branch, S_year)
 Primary key => P1 => S-rollno
d. Composite key:=> Whenever a primary key consists of more than one
attribute , it is known as composite key,
For example, In student table with attribute: (S_rollno, S_id,
S_name,S_branch)
Composite key:=> S_rollno, S_id
e. Foreign key:=> A foreign key is a column whose value is the same as
the primary key of another table. It combines two or more (relations)
at a time. They act as a cross reference between the tables. Foreign
key are the column of the table used to point the primary key of
another table.

2.5 Relationship types and sets:=>


Any association between two entity types is called a relationship.
Entities take part in the relationship.
It is represented by a Diamond shape.
Types of Relationships:=>
a. One-to-One Relationship
b. One-to-Many or Many-to-One Relationship
c. Many-to-Many Relationship

a. One-to-One Relationship:=>
The relationship that exist when each record of one table is
related to only one record of other table
Example:> One school has one principal.
b. One-to-many Relationship:=> A single entity in a table is
associated with multiple entities in another table, e.g., one
teacher can teach multiple classes.
c. Many-to-one Relationship:=> Multiple entities in a table are
associated with a single entity in another table, e.g., many
students can be enrolled in one course.

d. Many-to-Many Relationship:=> Multiple entities in one table are


associated with multiple entities in another table, e.g., many
students can enroll in many courses and many courses can have
many students.

Relationship types and sets:=>

In the context of databases, relationship types refer to the various ways in which
entities in different tables can be associated with each other. The primary
relationship types include one-to-one, one-to-many, many-to-one, and many-to-
many relationships, which describe how the records in one table can relate to
records in another.

Sets in this context refer to the collections of entities or records that participate in
these relationships. Each set is a group of entities that can be linked through a
defined relationship type. For example, in a one-to-many relationship between
teachers and classes, one set consists of teachers, and the other set consists of
classes, with the relationship defining how each teacher (entity in the first set)
can be associated with multiple classes (entities in the second set).

2.6 E-R diagrams:=>

An Entity Relationship Diagram is a diagram that represents relationships among


entities in a database. It is commonly known as an ER Diagram. An ER Diagram in
DBMS plays a crucial role in designing the database. ER Diagrams are most often
used to design or debug relational databases in the fields of software engineering,
business information systems, education and research. They use a defined set of
symbols such as rectangles, diamonds, ovals and connecting lines to depict the
interconnectedness of entities, relationships and their attributes.

The overall logical structure of a database can be expressed graphically by E-R


diagram which consist of following components: -

Rectangles, which represent entity sets. - Ellipses, which represent attributes.

- Diamonds which represent relationships among entity sets

-Lines, which links attributes to entity sets and entity set to relationship.
E r digarm of library mangement system
ER DIAGRAM OF restaurant
management system

ER diagram of hospital management


system
THANK YOU

You might also like