0 ratings0% found this document useful (0 votes) 53 views47 pagesData Modeling .2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Data Model
Data Model gives us an idea that
how the final system will took 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 organisation
can communicate and understand
it. Though there are many data
models being used nowadays but
the Relational model is the most
widely used model. Apart from the
Relational model, there are manyother types of data models about
which we will study in details in
this blog. Some of the Data Models
in DBMS are:
1. Hierarchical Model
2. Network Model
3. Entity-Relationship Model
4, Relational Model
5. Object-Oriented Data ModelHierarchical Model
Hierarchical Model was the first
DBMS model. This model organises
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. This model easily represents
some of the real-world
relationships like food recipes,
sitemap of a website etc. Example:
We can represent the relationship
between the shoes present on a
shopping website in the following
way:Women's:
Shoes (Real
Sports
Hierarchical Model
(tea) ‘s
Features of a Hierarchical Model
1. One-to-many relationship: The
data here is organised in a tree-
like structure where the one-
to-many relationship is
between the datatypes. 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 throughmens shoes node.
2. 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.
3. Deletion Problem: If a parent
node is deleted then the child
node is automatically deleted.
4. Pointers: Pointers are used to
link the parent node with the
child node and are used to
navigate between the stored
data. Example: In the above
example the ‘shoes' node points
to the two other nodes 'women
shoes' node and ‘men's shoes’
node.Advantages of Hierarchical Model
e It is very simple and fast to
traverse through a tree-like
structure.
e 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.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.CSE
Department
Student
Network Model
Features of a Network Model
1. 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.2.
WwW
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
e 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.
e 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
e 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.
e 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:e 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.
e 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 for a
department.Example:
Teacher_name ) ( Teacher_id
¢ ») ( ) opt id
Teacher von Department
Mobile_no Dept_name
Entity-Relationship
Model
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.Features of ER Model
e 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 modelcan also be converted to any
other model like network
model, hierarchical model etc.
Disadvatages 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.
e 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 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 Employee table.
[Emote Emp_name | Job_name | Salary
Mobile_no | Dep_id [Project |
‘Aftera001 John Engineer yoco09 | 9111037890
|
AfterA002 Adam Analyst 0000 | sss75e9214 | 3 | 100
‘AfterA003 Kande
Manager 90000 | 7895212355
[ss
EMPLOYEE TABLEFeatures 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
Salary, Mobile no, etc.Advnatages of Relational Model
e 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 cansay that structural
independence has been
achieved.
Disadvantages of Relatinal Model
e Hardware Overheads: For
hiding the complexities and
making things easier for the
user this model requires more
powerful hardware computers
and data storage devices.e 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.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.Employee Department |
‘ Attributes
Dept_ia
Methods
(Change Deparment
Object_Oriented_Model
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.What is ER Diagrams?
ENTITY-RELATIONSHIP DIAGRAM (ERD)
displays the relationships of entity set
stored in a database. In other words,
we can say that ER diagrams help you
to explain the logical structure of
databases. At first look, an ER diagram
looks very similar to the flowchart.
However, ER Diagram includes many
specialized symbols, and its meanings
make this model unique. The purpose
of ER Diagram is to represent the entity
framework infrastructure.
Apparel Size
size id
size code Product Colors
sort order colorid
Product Color
product name color id
product id color code
other data color name
Product Categories. |———————H| Categories
category id category id
parent category id
category nameFacts about ER Diagram Model:
ER model allows you to draw
Database Design
It is an easy to use graphical tool for
modeling data
Widely used in Database Design
It is a GUI representation of the
logical structure of a Database
It helps you to identifies the entities
which exist in a system and the
relationships between those
entities11:47 AM 2.4KB/s a
Here, are prime reasons for using the
ER Diagram
Helps you to define terms related to
entity relationship modeling
Provide a preview of how all your
tables should connect, what fields
are going to be on each table
Helps to describe entities,
attributes, relationships
ER diagrams are translatable into
relational tables which allows you
to build databases quickly
ER diagrams can be used by
database designers as a blueprint
for implementing data in specific
software applications
The database designer gains a
better understanding of the
information to be contained in the
database with the help of ERP
diagram
ERD is allowed you to communicate
with the logical structure of the
database to users
a @ 4Components of the ER
Diagram
This model is based on three basic
concepts:
e Entities
e Attributes
e Relationships
Example
For example, in a University database,
we might have entities for Students,
Courses, and Lecturers. Students
entity can have attributes like Rollno,
Name, and DeptID. They might have
relationships with Courses and
Lecturers.
-
‘ome _
Attribute
Property or characteristic of
Entxy
Person place objectevent Prep
orconcept about which = Ey + De tity
Example: Color of ear Entity
dota sto be maintained Name of Student Entity
‘Pxample: Car, StudentAssociation between the Instances of one or
more entity types
Example: Blue Car Belongs to Student Jack
WHAT IS ENTITY?
A real-world thing either living or non-
living that is easily recognizable and
nonrecognizable. It is anything in the
enterprise that is to be represented in
our database. It may be a physical
thing or simply a fact about the
enterprise or an event that happens in
the real world.
An entity can be place, person, object,
event or a concept, which stores data
in the database. The characteristics of
entities are must have an attribute,
and a unique key. Every entity is made
up of some ‘attributes' which
represent that entity.Examples of entities:
e Person: Employee, Student, Patient
¢ Place: Store, Building
¢ Object: Machine, product, and Car
Event: Sale, Registration, Renewal
e Concept: Account, Course
Notation of an EntityEntity set:
Student
An entity set is a group of similar kind
of entities. It may contain entities with
attribute sharing similar values.
Entities are represented by their
properties, which also called
attributes. All attributes have their
separate values. For example, a
student entity may have a name, age,
class, as attributes.
Example of Entities:
Auniversity may have some
departments. All these departments
employ various lecturers and offer
several programs.
Some courses make up each program.
Students register in a particularprogram and enroll in various courses.
A lecturer from the specific
department takes each course, and
each lecturer teaches a various group
of students.
Relationship
Relationship is nothing but an
association among two or more
entities. E.g., Tom works in the
Chemistry department.
@—_-@2
Entities take part in relationships. We
can often identify relationships with
verbs or verb phrases.
For example:
¢ You are attending this lecture
¢ lam giving the lecture
e Just loke entities, we can classifyrelationships according to
relationship-types:
e Astudent attends a lecture
e A lecturer is giving a lecture.
Weak Entities
Aweak entity is a type of entity which
doesn't have its key attribute. It can be
identified uniquely by considering the
primary key of another entity. For that,
weak entity sets need to have
participation.
In aboe example, "Trans No" is a
discriminator within a group of
transactions in an ATM.
Let's learn more about a weak entity
by comparing it with a Strong EntityStrong Entity Set
Strong entity set
always has a
primary key.
Itis represented
by a rectangle
symbol.
It contains a
Primary key
represented by
the underline
symbol.
The member of a
strong entity set
is called as
dominant entity
set.
Primary Key is
one of its
attributes which
helps to identify
its member.
Weak Entity Set
It does not have
enough
attributes to
build a primary
key.
It is represented
by a double
rectangle
symbol.
It contains a
Partial Key which
is represented by
a dashed
underline
symbol.
The member of a
weak entity set
called asa
subordinate
entity set.
In a weak entity
set, itisa
combination of
primary key and
partial key of the
strong entity set.In the ER
diagram the
relationship
between two
strong entity set
shown by using a
diamond
symbol.
The connecting
line of the strong
entity set with
the relationship
is single.
Attributes
The relationship
between one
strong anda
weak entity set
shown by using
the double
diamond
symbol.
The line
connecting the
weak entity set
for identifying
relationship is
double.
It is a single-valued property of either
an entity-type or a relationship-type.
For example, a lecture might have
attributes: time, date, duration, place,
etc.
An attribute is represented by an
EllipseTrans No
Types of Description
Attributes
Simple attribute Simple attributes
can't be divided
any further. For
example, a
student's contact
number. It is also
called an atomic
value.
Composite Itis possible to
attribute break down
composite
attribute. For
example, a
student's full
name may be
further dividedDerived attribute
Multivalued
attribute
further divided
into first name,
second name,
and last name.
This type of
attribute does
not include in
the physical
database.
However, their
values are
derived from
other attributes
present in the
database. For
example, age
should not be
stored directly.
Instead, it should
be derived from
the DOB of that
employee.
Multivalued
attributes can
have more than
one values. For
example, a
student can have
more than one
mobile number,
email address,
etc. _Cardinality
Defines the numerical attributes of the
relationship between two entities or
entity sets.
ER Diagram Examples y
Different types of cardinal
relationships are:
© One-to-One Relationships
¢ One-to-Many Relationships
* May to One Relationships
e Many-to-Many Relationships
Relationship cardinality
Mandatory one
O-_]-
Oo] led1.0ne-to-one:
One entity from entity set X can be
associated with at most one entity of
entity set Y and vice versa.
Example: One student can register for
numerous courses. However, all those
courses have a single line back to that
one student.
St
2.One-to-many:
One entity from entity set X can be
associated with multiple entities of
entity set Y, but an entity from entity
set Y can be associated with at least
one entity.
For example, one class is consisting of
multiple students.3. Many to One
More than one entity from entity set X
can be associated with at most one
entity of entity set Y. However, an
entity from entity set Y may or may not
be associated with more than one
entity from entity set X.
For example, many students belong to
the same class.
4. Many to Many:
One entity from X can be associated
with more than one entity from Y and
vice versa.For example, Students as a group are
associated with multiple faculty
members, and faculty members can be
associated with multiple students.
a=
ER- Diagram Notations
ER- Diagram is a visual representation
of data that describe how data is
related to each other.0000
Rectangles: This symbol represent
entity types
Ellipses : Symbol represent
attributes
Diamonds: This symbol represents
relationship types
Lines: It links attributes to entity
types and entity types with other
relationship types
Primary key: attributes are
underlined
Double Ellipses: Represent multi-
valued attributes
Entity or Strong Entity <> Relationship
Weak Entit
eee < Weak Relationship
Attribute
Multivalued Attributehe Enhanced Entity Relationship Model
contains all the features of the Entity
Relationship model. In addition to all that, it
also contains features of Subclasses,
Superclasses and Inheritance.
All of these in detail are as follows:
Subclasses
A subclass is a class derived from the
superclass. It inherits the properties of the
superclass and also contains attributes of its
own. An example is:Car, Truck and Motorcycle are all subclasses
of the superclass Vehicle. They all inherit
common attributes from vehicle such as
speed, colour etc. while they have different
attributes also i.e Number of wheels in Car is
4 while in Motorcycle is 2.
Superclasses
A superclass is the class from which many
subclasses can be created. The subclasses
inherit the characteristics of a superclass.
The superclass is also known as the parent
class or base class.
In the above example, Vehicle is the
Superclass and its subclasses are Car, Truck
and Motorcycle.
Inheritance
Inheritance is basically the process of basing
a class on another class i.e to build a class
ona existing class. The new class contains
all the features and functionalities of the old
class in addition to its own.
The class which is newly created is known
as the subclass or child class and the
original class is the parent class or the
superclass.Generalization
Generalization is a process of generalizing
an entity which contains generalized
attributes or properties of generalized
entities. The entity that is created will
contain the common features. Generalization
is a Bottom up process.
We can have three sub entities as Car, Truck,
Motorcycle and these three entities can be
generalized into one generai super class as
Vehicle.
VEHICLE
Specialization Generalation
|
Topdown
Approach
bottom up
Approach
MOTORCYCLEIt is a form of abstraction that specifies two
or more entities (sub class) having common
characters that can be generalized into one
single entity (super class) at higher level
hiding all the differences.
Specialization
Specialization is a process of identifying
subsets of an entity that shares different
characteristics. It breaks an entity into
multiple entities from higher level (super
class) to lower level (sub class). The
breaking of higher level entity is based on
some distinguishing characteristics of the
entities in super class.
It is a top down approach in which we first
define the super class and then sub class
and then their attributes and relationships.