0% found this document useful (0 votes)
4 views46 pages

Chapter 2 Data Models

Chapter 2 discusses the significance of data models in database design, introducing various types including hierarchical, network, relational, and object-oriented models. It outlines the basic building blocks of data models such as entities, attributes, relationships, and constraints, as well as the importance of business rules in shaping data structure. The chapter emphasizes the role of data models as communication tools that facilitate understanding among stakeholders and aid in effective database design.

Uploaded by

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

Chapter 2 Data Models

Chapter 2 discusses the significance of data models in database design, introducing various types including hierarchical, network, relational, and object-oriented models. It outlines the basic building blocks of data models such as entities, attributes, relationships, and constraints, as well as the importance of business rules in shaping data structure. The chapter emphasizes the role of data models as communication tools that facilitate understanding among stakeholders and aid in effective database design.

Uploaded by

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

Chapter 2

Data Models
The importance of data models,
Introduction to various data models
(hierarchical, Network, Relational, Entity
relationship and object model),
Basic building blocks, Business rules,
Degrees of data abstraction
In this chapter, you will learn:

Why data models are


important
About the basic data-modeling
building blocks
What business rules are and
how they affect database
design
How the major data models
Database Systems 6e / Rob & Coronel 2- 2
Data Model
Data Model gives us an idea that how the final
system will look like after its complete
implementation.
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
The Evolution of Data Models
i. Hierarchical Model
ii. Network Model
iii. Entity-Relationship Model
iv. Relational Model
v. Object-Oriented Data Model
vi. Object-Relational Data Model
vii.Flat Data Model
viii.Semi-Structured Data Model
ix. Associative Data Model
x. Context Data Model

Database Systems 6e / Rob & Coronel 2- 4


Building blocks of a Data Model
A data model is a structure of the data that
contains all the required details of the data
like the name of the data, size of the data,
relationship with other data and constraints
that are applied on the data. It is a
communication tool.
A data model constitutes of building blocks.
They are:
1. Entities
2. Attributes
3. Relationships
4. Constraints
Entities:
Entities are real time objects that exist. It can be a
person, place, object, event, concept. Entities are
represented by a rectangle box containing the entity
name in it.
Example: Student, employee.
Attributes:
It is the set of characteristics representing an entity.
It is represented by a ellipse symbol with attribute
name on it.
Example: A student has attributes like name, roll
number, age and much more.
January 18, 2024 Data Models in DBMS 6
Relationship:

It describes the association between two entities. It is


represented using diamond symbol containing relationship
name with it. The data model generally uses different
kinds of relationships: one to many, many to many, one to
one and many to one. Example: The relationship between
two entities Student and Class has many to many
relationship.

Constraints:

Constraints are conditions applied on the data. It provides


the data integrity. Example: A student can take a
maximum of 2 books from the library is applied as a
constraint on the student database.
Keys:
Keys play an important role in the relational
database.
It is 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,
Primary key:
It is the first key used to identify one and only one instance of an
entity uniquely. An entity can contain multiple keys, as we saw in
the PERSON table. The key which is most suitable from those lists
becomes a primary key.
In the EMPLOYEE table, ID can be the primary key since it is
unique for each employee. In the EMPLOYEE table, we can even
select License_Number and Passport_Number as primary keys
since they are also unique.
Candidate key:
A candidate key is an attribute or set of attributes that can
uniquely identify a tuple.
Except for the primary key, the remaining attributes are
considered a candidate key. The candidate keys are as strong as
the primary key.
For example: In the EMPLOYEE table, id is best suited for the
primary key. The rest of the attributes, like SSN,
Super Key
Super key is an attribute set that can uniquely identify
a tuple.
A super key is a superset of a candidate key.

Foreign key
Foreign keys are the column of the table used to point
to the primary key of another table.
Every employee works in a specific department in a
company, and employee and department are two
different entities. So we can't store the department's
information in the employee table. That's why we link
these two tables through the primary key of one table.
We add the primary key of the DEPARTMENT table,
Department_Id, as a new attribute in the EMPLOYEE
Hierarchical Model
Features of a Hierarchical Model
One-to-many relationship: The data here is
organized in a tree-like structure where the one-to-
many relationship is between the data types. Also,
there can be only one path from parent to any
node. Example: In the above example, if we want to
go to the node sneakers we only have one path to
reach there i.e. through men's shoes node.
Parent-Child Relationship: Each child node has a
parent node but a parent node can have more than
one child node. Multiple parents are not allowed.
Deletion Problem: If a parent node is deleted then
the child node is automatically deleted.
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
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 shown
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
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.
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:
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.
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.
Relationship: Relationship tells how two
attributes are related. Example: Teacher works
Features of ER Model
Graphical Representation for Better
Understanding: It is very easy and simple to
understand so it can be used by the
developers to communicate with the
stakeholders.
ER Diagram: ER diagram is used as a visual
tool for representing the model.
Database Design: This model helps the
database designers to build the database and
is widely used in database design.
Advantages of ER Model
Simple: Conceptually ER Model is very easy to build. If we know
the relationship between the attributes and the entities we can
easily build the ER Diagram for the model.
Effective Communication Tool: This model is used widely by
the database designers for communicating their ideas.
Easy Conversion to any Model: This model maps well to the
relational model and can be easily converted relational model by
converting the ER model to the table. This model can also be
converted to any other model like network model, hierarchical
model etc.
Disadvantages of ER Model
No industry standard for notation: There is no industry
standard for developing an ER model. So one developer might use
notations which are not understood by other developers.
Hidden information: Some information might be lost or hidden
in the ER model. As it is a high-level view so there are chances that
some details of information might be hidden.
Relational Model
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 this example, we have an
Features of Relational Model
Tuples: Each row in the table is called tuple.
A row contains all the information about any
instance of the object. In the above example,
each row has all the information about any
specific individual like the first row has
information about John.
Attribute or field: Attributes are the
property which defines the table or relation.
The values of the attribute should be from the
same domain. In the above example, we have
different attributes of the employee like
Advantages 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.
Evolution of Major Data Models

Database Systems 6e / Rob & Coronel 2- 28


Relational Model
All the data is stored in various tables. Columns
Example of tabular data in the relational model

Rows
A Sample Relational Database
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.
In this model, two or more objects are
connected through links. We use this link to
relate one object to other objects
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.
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.
The flat (or table) model consists of a
single, two-dimensional array of data
elements, where all members of a given
column are assumed to be similar values, and
all members of a row are assumed to be
The Importance of Data Models
Data model
◦ Relatively simple representation, usually
graphical, of complex real-world data
structures
◦ Communications tool to facilitate interaction
among the designer, the applications
programmer, and the end user

Good database design uses an


appropriate data model as its foundation
Database Systems 6e / Rob & Coronel 2- 36
Importance of Data Modeling
End-users have different views and
needs for data

Data model organizes data for various


users

Database Systems 6e / Rob & Coronel 2- 37


Data Model Basic Building Blocks
Entity is anything about which data are to
be collected and stored
Attribute is a characteristic of an entity
Relationship describes an association
among (two or more) entities
◦ One-to-many (1:M) relationship
◦ Many-to-many (M:N or M:M) relationship
◦ One-to-one (1:1) relationship
Database Systems 6e / Rob & Coronel 2- 38
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. For example, a student's
name cannot be a numeric value. It has to be
alphabetic. A student's age cannot be negative, etc.
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.
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.
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.
Business Rules
Brief, precise, and unambiguous description of a
policy, procedure, or principle within a specific
organization’s environment
◦ A company airplane must be inspected after 100 hours of
flight time
◦ A customer may generate many invoices
◦ Each invoice is generated by only one customer
Apply to any organization that stores and uses data
to generate information
Description of operations that help to create and
enforce actions within that organization’s
environment Database Systems 6e / Rob & Coronel 2- 41
Business Rules cont…
Business Rules are used every day to define
entities, attributes, and relationships.
 Usually though they are used for the organization
that stores or uses data to be an explanation of a
policy, procedure, or principle.
The data can be considered significant only after
business rules are defined, without them it’s just
records, but to a business they are the
characteristics that are defined and seen by the
company.
Business Rules help employees focus on and
implement the actions within the organizations
Business Rules (continued)
Must be rendered in writing
Must be kept up to date
Sometimes are external to the
organization
Must be easy to understand and widely
disseminated
Describe characteristics of the data as
viewed by the company
Database Systems 6e / Rob & Coronel 2- 43
Sources of Business Rules
Company managers
Policy makers
Department managers
Written documentation
◦ Procedures
◦ Standards
◦ Operations manuals
Direct interviews with end users

Database Systems 6e / Rob & Coronel 2- 44


Importance of Business Rules
Promote creation of an accurate data
model
Standardize company’s view of data
Constitute a communications tool
between users and designers
Allow designer to understand the
nature, role, and scope of data
Allow designer to understand business
processes
Allow designer to develop appropriate
relationship participation
January 18, 2024
rules and
Database Systems 6e / Rob & Coronel 2- 45
Example

You might also like