Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 22

Data modeling

The various database models


Databases appeared in the late 1960s, at a time
when the need for a flexible information
management system had arisen. The two most
common types of models are the:

– Hierarchical
– Network
The hierarchical model:
• The data is sorted hierarchically, using a
downward tree. This model uses pointers
to navigate between stored data. It was
the first DBMS model.
Hierarchical Model

• The hierarchical data model organizes data in a


tree structure.
• There is a hierarchy of parent and child data
segments.
• This structure implies that a record can have
repeating information, generally in the child
data segments.
To create links between these record types, the
hierarchical model uses Parent Child
Relationships.
In a hierarchical database the parent-child
relationship is one to many. This restricts a child
segment to having only one parent segment.
Hierarchical DBMSs were popular from the late
1960s, with the introduction of IBM's Information
Management System (IMS) DBMS, through the
1970s.
Example
For example, an organization might store
information about an employee, such as name,
employee number, department, salary. The
organization might also store information about an
employee's children, such as name and date of
birth. The employee and children data forms a
hierarchy, where the employee data represents
the parent segment and the children data
represents the child segment. If an employee has
three children, then there would be three child
segments associated with one employee segment.
The network model:
• like the hierarchical model, this model
uses pointers toward stored data.
However, it does not necessarily use a
downward tree structure.
Network Model

• The network model permitted the modeling of


many-to-many relationships in data.
• The basic data modeling construct in the
network model is the set construct.
• A set consists of an owner record, a set name,
and a member record.
• A member record can have that role in more
than one set, hence the multiparent concept is
supported.
• An owner record can also be a member or
owner in another set.
Thus, the complete network of relationships is
represented by several pair wise sets; in each set
some (one) record type is owner and one or more
record types are members.

Manager1 Manager2
Ram 36 Delhi Ravi 37 Mum

Raju 27 Delhi Raj 25 Mum

Employee1 Employee2
NORMALIZATION
Normalization
• Protecting your data integrity by avoiding
duplicate data.
• The normalization guidelines are most
useful when you’ve identified which
columns go in which table.
Normalization
• Set of design standards called normal
forms
• Making your tables match these standards
is normalization
• Form progresses in order from first
onwards.
• Each form implies that the requirements of
the previous form have been met
Why Normalize?
• Normalization guidelines involves splitting tables
into two or more tables with fewer columns,
designating primary-foreign key relationships
into new smaller tables that can be reconnected
with the join operation.
• This help reduce data redundancy within tables
• The maintenance of consistency between
primary and foreign keys is a major point of
referential integrity.
First Normal Form (1NF)

• There are no repeating or duplicate fields.


• Each cell contains only a single value.
Example
item colors price tax
sweatshirt blue, black 25.00 1.25
T-shirt1 red, orange 12.00 0.60
polo brown, 12.00 0.60
yellow
T-shirt2 white, violet 12.00 0.60

• Table is not in first normal form because:


Multiple items in color field
Example
item colors price tax
T-shirt1 red 12.00 0.60
T-shirt1 orange 12.00 0.60
polo brown 12.00 0.60
polo yellow 12.00 0.60
sweatshirt blue 25.00 1.25
sweatshirt black 25.00 1.25

Table is now in first normal form


Second Normal Form (2NF)

• All non-key fields depend on all


components of the primary key.

• Guaranteed when primary key is a single


field.
Example
itemid item colors price tax
i001 T-shirt1 red 12.00 0.60
i002 T-shirt2 orange 12.00 0.60
i003 polo1 brown 12.00 0.60
i004 polo2 yellow 12.00 0.60
I005 sweatshi blue 25.00 1.25
rt

Table is not in second normal form because:


• price and tax depend on itemid, but not color
itemid colors itemid price tax
i001 red i001 12.00 0.60
i002 orange i002 12.00 0.60
i003 brown i003 12.00 0.60
i004 yellow i004 12.00 0.60
I005 blue I005 25.00 1.25

Tables are now in second normal form


Third Normal Form (3NF)

• No non-key field depends upon another.


• All non-key fields depend only on the
primary key.
itemid colors itemid price tax
i001 red i001 12.00 0.60
i002 orange i002 12.00 0.60
i003 brown i003 12.00 0.60
i004 yellow i004 12.00 0.60
I005 blue I005 25.00 1.25

Tables are not in Third normal form as tax


depends on price and not itemid

You might also like