Data Models Lec3
Data Models Lec3
E-OGODO (MRS)
Lecture Content
What is a Data Model?
Hierarchical Data Model.
Network Data Model
Entity-Relationship Model
Relational Model
Introduction
Data models describe how a database’s logical structure is
represented. In a DBMS, data models are essential for
introducing abstraction.
Data Abstraction is a process of hiding unwanted or
irrelevant details from the end user. It provides a different
view and helps in achieving data independence which is
used to enhance the security of data.
Data models specify how data is linked to one another, as
well as how it is handled and stored within the system.
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.
Definitions
A data model can be defined as an integrated collection of concepts
describing and manipulating data, as well as constraints on the
data within an organization.
A data model is a representation of real-world entities like objects,
events and their association
For instance, a data model may specify that the data element
representing a car be composed of several other elements which, in
turn, represent the color and size of the car and define its owner.
A data model is not just a set of tables; it is a conceptual
representation of physical data stored in the database.
A data model establishes the structure of data elements and the
relationships among them. It is independent of the physical
database that details how the data will be implemented. The logical
data model serves as a blueprint for used data.
Types of Data Models in
DBMS
There are a variety of models for data. Some of the most well-
known models include:
Hierarchical model
Network model
Entity-Relationship Model
Relational Model
Object-Oriented Data Model
Object-Relational Data Model
Flat Data Model
Semi-Structured Data Model
Associative Data Model
Context Data Model
Hierarchical Data Model
A hierarchical model represents the data in a tree-like
structure in which there is a single parent for each record.
To maintain order there is a sort field which keeps sibling
nodes into a recorded manner.
These types of models are designed basically for the early
mainframe DBMS, like the Information Management
System (IMS) by IBM.
This model structure allows the one-to-one and a one-to-
many relationship between two/ various types of data.
This structure is very helpful in describing many
relationships in the real world; table of contents, any
nested and sorted information.
Hierarchical Model
Demerits of
Hierarchical Model
Even though this model is conceptually simple and easy to
design at the same time it is quite complex to implement.
The earliest model was the hierarchical database model,
resembling an upside-down tree. Files are related in a parent-
child manner, with each parent capable of relating to more than
one child, but each child only being related to one parent.
This model also lacks flexibility as the changes in the new tables
or segments often yield very complex system management
tasks.
Here, a deletion of one segment can lead to the involuntary
deletion of all segments under it.
It has no standards as the implementation of this model does
not provide any specific standard.
Network Data Model
A network data model is a database model that allows multiple
records to be linked to the same owner file. The model can be
seen as an upside down tree where the branches are the
member information linked to the owner, which is the bottom
of the tree.
The network database model was a progression from
the hierarchical data model and was designed to solve some of
that model's problems, specifically the lack of flexibility.
Instead of only allowing each child to have one parent, this
model allows each child to have multiple parents (it calls the
children members and the parents owners).
It addresses the need to model more complex relationships
such as the orders/parts many-to-many relationship.
Example of Network
Data Model
Network Models
Relationships in
Network Model
A one-to-one relationship (1:1). For example, if each
customer in a database is associated with one mailing
address.
A one-to-many relationship (1:M). For example, a single
customer might place an order for multiple products. The
customer is associated with multiple entities, but all those
entities have a single connection back to the same
customer.
A many-to-many relationship (M:N). For example, at a
company where all call center agents work with multiple
customers, each agent is associated with multiple
customers, and multiple customers might also be
associated with multiple agents.
Relationships in
Network Model
Entity-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 Entity Relationship Diagram explains the relationship
among the entities present in the database.
It was introduced in 1976 by Peter Chen.
It is a diagrammatic technique used for analyzing data.
The diagrams can be used to derive relational tables.
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.
ER Symbols & Meanings
ER Terminology
Entity- this represents the name of an object, person, thing, event, or place
where data is stored. This is usually represented by rectangles.
Weak Entity- unlike a strong entity that is defined by its attributes, a weak
entity solely depends on the existence of another entity.
Attribute- refers to the unique characteristic or property of an entity.
Derived Attribute- refers to an attribute derived or based on another
attribute.
Multivalued Attribute- a type of attribute that can have multiple values.
Relationship- defines the interaction between two entities. For eaxmple
“employs” exists between Company and Employee.
Cardinality- this refers to the occurrences of a relationship. In particular, it
specifies the maximum number of relationships between two entities.
How to Draw an ER
Diagram
The very first step is Identifying all the Entities, and place
them in a Rectangle, and labeling them accordingly.
The next step is to identify the relationship between them
and pace them accordingly using the Diamond, and make
sure that, Relationships are not connected to each other.
Attach attributes to the entities properly.
Remove redundant entities and relationships.
Add proper colors to highlight the data present in the
database.
ER Diagram (1)
ER Diagram (2)
Converting Relations
(Table) to ER diagrams
Relational Data Model
E.F. Codd proposed the relational Model to model data in the
form of relations or tables.
Relational Model (RM) represents the database as a collection
of relations.
A relation is nothing but a table of values. Every row in the
table represents a collection of related data values. These rows
in the table denote a real-world entity or relationship.
The relational model represents how data is stored in Relational
Databases. A relational database consists of a collection of
tables, each of which is assigned a unique name.
After designing the conceptual model of the Database using ER
diagram, we need to convert the conceptual model into a
relational model which can be implemented using
any RDBMS language like Oracle SQL, MySQL, etc.
Relational Model
Terminology (1)
Attribute: Each column in a Table. Attributes are the properties
which define a relation. e.g., Student_Rollno, NAME,etc.
Tables – In the Relational model the, relations are saved in the
table format. It is stored along with its entities. A table has two
properties rows and columns. Rows represent records and
columns represent attributes.
Tuple – It is nothing but a single row of a table, which contains
a single record.
Relation Schema: A relation schema represents the name of the
relation with its attributes.
Degree: The total number of attributes which in the relation is
called the degree of the relation.
Cardinality: Total number of rows present in the Table.
Relational Model
Terminology (2)
Column: The column represents the set of values for a specific attribute.
Relation instance – Relation instance is a finite set of tuples in the RDBMS
system. Relation instances never have duplicate tuples.
Attribute domain – Every attribute has some pre-defined value and scope
which is known as attribute domain
Primary Key (of a table): it is a column (or combination of two or columns)
that serves to identify the individual rows of a table. Example is the matric
number of a students’ table to uniquely identify each student as no two
student can have the same matric number.
Composite Key: This is when the primary key consists of more than one
column.
Foreign Key: it is a column in one table that refers to the primary key of
another table. In other words, the foreign key is defined in second table,
but it refers to the primary key in the first table.
Summary
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.
Types of data models include Hierarchical, Network,
Entity- Relationship and Relational Data Models.
The relational model performs some functions of
both the hierarchical and the network model.
Relational Model (RM) represents the database as a
collection of relations.