Download as pdf or txt
Download as pdf or txt
You are on page 1of 51

Chapter-3

INTRODUCTION TO DATA MODELS


CONTENTS
2

Introduction.
Data Models
Importance of data models
Database modeling Techniques
Hierarchical
Network
Relational
Entity Relationship model
Comparison between models
Important questions
2
Introduction
3

A model is a representation of reality, ‘real world’


objects and events, and their associations.
Data Model is defined as Planning the structure of
database is called data models.
It involves planning about tables, their columns,
mapping between the tables, how they are structured
in the physical memory etc.
Data Models
4

◻ Data model can be defined as integrated collection


of components for describing and manipulating
data, relationships between data, constraints on
data in organization.
◻ Data model has three components:
◻ A structural part consisting of set of rules according
to which database can be constructed.
◻ A manipulative part, defining the types of
operations that are allowed on data.
◻ Set of integrity rules to ensure that data is accurate.
Categories of Data Models

◻ The object based and record based data models are


used to describe data at the conceptual and external
levels, the physical data model is used to describe data
at the internal level.
Physical Data Models
◻ Physical data models describe how data is stored in
the computer.
◻ Most common is Unifying Model.
◻ Not in scope at this moment of time.
Record based logical models
◻ Record based logical models are used in describing
data at the logical and view levels.
◻ The three most widely accepted record based data
models are :
Hierarchical Model
Network Model
Relational Model
Hierarchical model
◻ Hierarchical Database model is one of the oldest
database models.
◻ Information Management System (IMS) is based on
this model .
◻ This model is like structure of tree with records
forming the nodes and fields forming branches of tree
.
Example:
Sample database
Equivalent Hierarchical Model
Operations on Hierarchy
model
◻ Insert Operation: It is not possible to insert the data
of the supplier e.g. S4 who does not supply any
part. This is because a node cannot exist without a
root.
◻ So, we can say that insert anomaly exists only for
those children, which has no corresponding parents.
◻ Update Operation: Suppose we wish to change the city
of supplier S1 from Qadian to Jalandhar, then we will
have to carry out two operations such as searching S1
for each part and then multiple updations for different
occurrences of S1.
◻ But, if we wish to change the city of part P1 from
Qadian to Jalandhar, then these problems will not occur
because there is only a single entry for part P I and the
problem of inconsistency will not arise.
◻ So, we can say that update anomalies only exist for
children not for parent because children may have
multiple entries in the database.
◻ Deletion Operation: This model is suffer from
deletion anomaly too.
Example: Supplier S2 stops supplying 250 quantity of
part PI, then the whole record of S2 has to be
deleted under part PI which may lead to loss the
information of supplier.
◻Record Retrieval: Record retrieval methods for
hierarchical model are complex and asymmetric
which can be clarified with the following queries:
Query1: Find the supplier number for suppliers who
supply part P2.
Solution: In order to get this information, first we
search the information of parent P2 from database,
since parent occurs only once in the whole database,
so we obtain only a single record for P2. Then, a
loop is constructed to search all suppliers under this
part and supplier numbers are printed for all
suppliers
Advantages of Hierarchical
Model
1. Simplicity: Data naturally have hierarchical relationship
in most of the practical situations. Therefore, it is easier to
view data arranged in manner.
2. Data Security: These database system can enforce
varying degree of security feature unlike flat-file system.
3. Data Integrity: Because of its inherent parent-child
structure, database integrity is highly promoted in these
systems.
4. Efficiency: The hierarchical database model is a very
efficient, one when the database contains a large
number of I: N relationships (one-to-many relationships)
and when the users require large number of transactions.
Disadvantages
1. Complexity of Implementation: The actual
implementation of a hierarchical database depends on
the physical storage of data. This makes the
implementation complicated.
2. Difficulty in Management: The movement of a data
segment from one location to another cause all the
accessing programs to be modified making database
management a complex affair.
3. Complexity of Programming: Programming a
hierarchical database is relatively complex because the
programmers must know the physical path of the data
items.
4. Poor Portability: The database is not easily portable mainly
because there is little or no standard existing for these types
of database.
5. Database Management Problems: If you make any changes
in the database structure of a hierarchical database, then you
need to make the necessary changes in all the application
programs that access the database.
6. Lack of structural independence: Structural independence
exists when the changes to the database structure does not
affect the DBMS ability to access data. Hierarchical database
systems use physical storage paths to navigate to the
different data segments. If the physical structure is changed
the applications will also have to be modified.
7. Operational Anomalies: As discussed earlier,
hierarchical model suffers from the Insert anomalies,
Update anomalies and Deletion anomalies, also the
retrieval operation is complex and asymmetric, thus
hierarchical model is not suitable for all the cases.
8. Implementation Limitation: Many of the common
relationships do not conform to the l:N format
required by the hierarchical model. The
many-to-many (N:N) relationships, which are more
common in real life are very difficult to implement in
a hierarchical model.
Network Model
◻ The Network model represents data with a graph.
◻ Data is represented as collection of records and
relationship among data by links which can be
represented by pointer.
◻ The main difference of the network model from the
Hierarchical Model is its ability to handle many to
many (N:N) relations.
Hierarchical model of Customer
loan relationship in banking system.
Customer(id,name,street,city) account(loan_id,amount)

•Root
•C1 Rahat Thapar Campus patial
•L1 10000

•C3 Chahat Dharampura Qadian


•L2 15000
•L3 25000

•C2 Ruhi Tagore Nagar Jalandar


•L1 10000
Operations on Network Model
◻ Insert Operation: To insert a new record containing the
details of a new supplier, we simply create a new
record occurrence. Initially, there will be no connector.
◻ For example, supplier S4 can be inserted in network
model that does not supply any part as a new record
occurrence with a single pointer from S4 to itself. This is
not possible in case of hierarchical model. Similarly a
new part can be inserted who does not supplied by any
supplier.
◻ There is no insert anomalies in network model as in
hierarchical model.
◻ Update Operation: Unlike hierarchical model, where
updation was carried out by search and had many
inconsistency problems, in a network model updating
a record is a much easier process.
◻ We can change the city of S1 from Qadian to
Jalandhar without search or inconsistency problems
because the city for S1 appears at just one place in
the network model.
◻ Delete operation: If we wish to delete the
information of any part say PI, then that record
occurrence can be deleted by removing the
corresponding pointers and connectors, without
affecting the supplier who supplies that part i.e. P1,
the model is modified as shown.
◻ Similarly, same operation is performed to delete the
information of supplier.
Advantages
◻ Conceptual simplicity: Just like the hierarchical model, the
network model IS also conceptually simple and easy to
design.
◻ Capability to handle more relationship types: The network
model can handle the one to- many (l:N) and many to many
(N:N) relationships, which is a real help in modeling the real
life situations.
◻ Ease of data access: The data access is easier and flexible
than the hierarchical model.
◻ Data Integrity: The network model does not allow a member
to exist without an owner. Thus, a user must first define the
owner record and then the member record. This ensures the
data integrity.
Disadvantages
◻ System complexity: All the records are maintained using
pointers and hence the whole database structure becomes
very complex.
◻ Operational Anomalies: network model's insertion, deletion
and updating operations of any record require large number
of pointer adjustments, which makes its implementation very
complex and complicated.
◻ Absence of structural independence: Since the data access
method in the network database model is a navigational
system, making structural changes to the database is very
difficult in most cases and impossible in some cases. If
changes are made to the database structure then all the
application programs need to be modified
Relational model
◻ Relational model stores data in the form of tables.
◻ This concept purposed by Dr. E.F. Codd, a
researcher of IBM in 1970.
◻ This model consist of three major components
Set of relation and set of domain (data structure)
Integrity Rules
Operations performed on data(data manipulation)
Example
Sample database
TERMINOLOGIES
◻ Cardinality of the relation: Number of tuples in
relation.
◻ Degree of relation: Number of attributes or fields in
relation.
◻ Domain: Specifies the kind of data represented by
attribute i.e. set of allowed values.
Example : 600 students, so roll no of student may be from
101 to 700
Domain information include(data type, length, contraits)
◻ Advantages:
◻ Structural independence: In relational model,
changes in the database structure do not affect the
data access. So, relational database model has
structural independence.
◻ Conceptual simplicity: relational database model is
even simpler than network and hierarchical data
model at the conceptual level. Since the relational
data model frees the designer from the physical
data storage details, the designers can concentrate
on the logical view of the database.
◻ Design, implementation, maintenance and usage
ease: The relational database model\ achieves both
data independence and structure independence making
the database design, maintenance, administration and
usage much easier than the other models.
◻ Query capability: The presence of very powerful,
flexible and easy-to-use query capability is one of the
main reasons for the immense popularity of the
relational database model. The query language of the
relational database models structured query language
or SQL makes ad hoc queries a reality.
Disadvantages

◻ Hardware overheads: the relational database


systems need more powerful hardware computers
and data storage devices for its efficient working.
◻ Ease of design can lead to bad design: The
relational database is an easy to design and use.
The users need not know the complex details of
physical data storage. This ease of design and use
can lead to the development and implementation of
very poorly designed database management
systems.
Entity Relationship model
◻ The Entity-Relationship (ER) model was originally
proposed by Peter in 1976
◻ It combines the network and relational database
views.
◻ The ER model is a conceptual data model that views
the real world as entities and relationships.
◻ A basic component of the model is the
Entity-Relationship diagram.
Entity-Relationship diagram
◻ ER-Diagram is a visual representation of data that
describes how data is related to each other.
Symbols used in ER diagram

Rectangle: Represent Entity set

Ellipse: Represent attributes

Diamond: represent relationship

Lines: Link attributes to entities and relationships


C_id Loan_id Amount
Address

Cust_l
customer loan
oan

P_no
City
Advantages:
◻ It makes the requirement simple and easily
understandable by representing simple diagrams.
◻ One can covert ER diagrams into record based
data model easily.
◻ Easy to understand ER diagrams
Disadvantages
◻ No standard notations are available for ER
diagram. There is great flexibility in the notation.
It’s all depends upon the designer, how he draws it.
◻ It is meant for high level designs. We cannot simplify
for low level design like coding.
Object-Oriented Model
◻ Object oriented database models have been
around since the seventies when the concept of
object oriented programming was first explored.
◻ It is only in the last ten or fifteen years that
companies are utilizing object oriented DBMSs
(OODBMS).
◻ OODBMS should be used when there is a business
need, high performance required, and complex
data is being used.
Components of object data
model
◻ Object: Abstraction of real world thing.
◻ An object class: set of objects with shared attributes.
i.e. object that shares similar characteristics are
grouped in classes.
◻ Attributes: properties of objects.
Advantages

◻ Capacity to handle large number of data types :


Unlike hierarchical ,network and relation data
models , this also stores audios ,pictures and videos
including text and number.
◻ Combination of object oriented programming and
database technology.
◻ Object oriented features improve productivity :
Feature like inheritance ,polymorphism and dynamic
binding provide productive advantage to database
application developers.
Disadvantages
◻ Difficult to maintain: Updation require change in
code associate with each objects ,hence difficult to
maintain.
◻ Not suited for all application: This model is only
used in limited areas like e-commerce ,engineering
product data management ,database in security
and medicine etc.
Comparison Between Hierarch1al ,network and relational
data model

Hierarchical Network model Relational model


Characteristic
model
Data structure organizes data in organizes data in Store data in table
a tree structure graph form form
Data structure One to many or Allowed the One to One,
one to one network model to One to many,
relationships support many to Many to many
many relationships
relationships
Data structure Based on parent A record can have Based on
child relationship many parents as relational data
well as many structures
children.
Data manipulation retrieve Retrieve Retrieve
algorithms are algorithms are algorithms are
complex and complex and simple and
asymmetric symmetric symmetric
Data integrity Cannot insert the Does not suffer Does not suffer
information of a form any insertion from any insert
child who does not anomaly. anomaly.
have any parent.

Data integrity Multiple Free from update Free form update


occurrences of child anomalies. anomalies
records which lead
to problems of
inconsistency during
the update
operation

Data integrity Deletion of parent Free from delete Free from delete
results in deletion anomalies anomalies
of child records
Important Questions
◻ Compare the features of Network, Hierarchical and
Relational model with the help of examples(10)
◻ Discuss the concept of entity relationship model. How
it helps in designing relational database? (10)
◻ Discuss the concept of entity relationship model. How
it helps in designing relational database.(10)
◻ What is ER model?(2)
◻ What do you meant by data models? Explain network
model in detail.

You might also like