You are on page 1of 37

Chapter 5:

Data Modeling Concepts

1
Definition

• A Data Model is a logical structure of Database.

• It describes the design of database to reflect


entities, attributes, relationship among data,
constrains(NOT NULL , UNIQUE , PRIMARY KEY,
FOREIGN KEY etc) etc.

2
Categories of data modeling
Hierarchical database model

Network model

Relational model

Object-oriented database model

Entity-relationship model

3
Hierarchical database model
 In hierarchical model, data is organized into a tree like
structure with each record is having one parent record or
root and many children.
 The hierarchical database model mandates that each
child record has only one parent, whereas each parent
record can have one or more child records.
 In order to retrieve data from a hierarchical database the
whole tree needs to be traversed starting from the root
node.
4
Fig 18. Example of Hierarchical Model

Fig 17. Structure of Hierarchical Model

The hierarchical database model looks like an organizational chart or a family tree.
It has a single root segment (Employee) connected to lower level segments
(Compensation, Job Assignments, and Benefits).
Each subordinate segment, in turn, may connect to other subordinate segments. Here,
Compensation connects to Performance Ratings and Salary History.

5
Advantages of Hierarchical Model
Disadvantages Cont’
Easy to understand One parent per child.
Performance is better than Navigation system is
relational data model complex.
Many too many
Disadvantages of Hierarchical Model relationships not supported.
Data independence.
Difficult to access values at lower
level
Deletion of parent node result in
deletion of child node forcefully
Extra space is required for the
storage of pointers
6
Network Model

 In network models, the entities are organized in graph, in


which some entities can be accessed through several paths.

 Network Model is same as hierarchical model except that it


has graph-like structure rather than a tree-based structure.

 Unlike hierarchical model, this model allows each record to


have more than one parent record.

7
Figure 19: Network Model

8
Relational model
 In relational model, the data and relationships are represented
by collection of inter-related tables.

 Each table is a group of column and rows, where column


represents attribute of an entity and rows represents records or
tuples.

Figure 20:Relational Model Terms


9
Object Oriented Database Model
An object database (also object-oriented
database management system, OODBMS) is a
database management system in which information is represented
in the form of objects as used in object oriented programming.

10
Figure 21:Object-Oriented Model 11
This model was primarily used by IBM’s
Information Management Systems in the 60s
and 70s, but they are rarely seen today due to
certain operational inefficiencies.

12
Disadvantages

It is not widely developed and complete to use


it in the database systems. Hence it is not
accepted by the users.
It is an approach for solving the requirement.
It is not a technology. Hence it fails to put it in
the database management systems.

13
Difference between Object-oriented database
Model & Relational Model

Figure 21.a:Difference between Object-oriented database


Model & Relational Model
14
Entity Relationship Model

 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.

15
16
 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.

 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.

17
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.

18
 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.

• Other example is age from Date of Birth and Today’s


date.
19
 Composite attribute − Composite attributes are
made of more than one simple attribute.

• For Example, Name can be divided into First


name, Middle name and Last name.

20
 Single-value attribute − An attribute, that has a
single value for a particular entity is known as
single valued attributes.

• For example, age of a employee entity.

• For example − Social_Security_Number.

21
 Multi-value attribute − An attributes that may
have multiple values for the same entity is known
as multi valued attributes.

• For example colors of a car entity.

• For example, a person can have more than one


phone number, email_address, etc.

22
Entity-Set and Keys

An entity set is a set of entities of the same type


(e.g., all persons having an account at a bank).

 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.

23
Candidate keys are defined as the set of fields
from which primary key can be selected.

 It is an attribute or set of attribute that can


act as a primary key for a table to uniquely
identify each record in that table.

24
 Super Key − is defined as a set of attributes within a
table that uniquely identifies each record within a
table.
 Super Key is a superset of Candidate key.
 Primary Key − A primary key is one of the candidate
keys chosen by the database designer to uniquely
identify the entity set.
Notes:
• Primary key in ERD is underlined.

25
26
Composite Key: Key that consist of two or more
attributes that uniquely identify an entity occurance is
called Composite key.
But any attribute that makes up the Composite key is
not a simple key in its own.

27
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.

Figure 22:One-to-one Relationship 28


 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.

Figure 23:One-to-many
29
 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.

Figure 24:Many-to-one
30
 Many-to-many − One entity from A can be associated with
more than one entity from B and vice versa.

Figure 24:Many-to-many
31
ER Diagram Representation
 Entity
• Entities are represented by means of rectangles.
• Rectangles are named with the entity set they represent.

 Attributes
• Attributes are represented by means of ellipses.
• Every ellipse represents one attribute and is directly
connected to its entity (rectangle).

32
• If the attributes are composite, they are further divided in
a tree like structure.

• Multi-valued attributes are depicted by double ellipse.

33
• Derived attributes are depicted by dashed ellipse.

34
Relationships
• One-to-one

•One-to-many

•Many-to-one

•Many-to-many

35
Transforming the E-R Data Model
to the Relational Data Model

• The E-R model and the relational model are


actually closely related:
– Entities in the E-R model become tables in the
relational model
– Attributes of in the E-R model are the table
columns in the relational model
– Relationships in the E-R model are represented by
a common attribute

36
DEPARTMENT

Belongs to

37

You might also like