4.data Models
4.data Models
Data Models
Data Model is the modeling of the data description, data
semantics, and consistency constraints of the data. It
provides the conceptual tools for describing the design of
a database at each level of data abstraction. Therefore,
there are following four data models used for
understanding the structure of the database:
2
Relational Data Models
This type of model designs the data in the form of rows
and columns within a table. Thus, a relational model uses
tables for representing data and in-between relationships.
Tables are also called relations.
This model was initially described by Edgar F. Codd, in
1969. The relational data model is the widely used model
which is primarily used by commercial data processing
applications.
3
Relational Data Models
Relational data model is the primary data model, which is
used widely around the world for data storage and
processing. This model is simple and it has all the
properties and capabilities required to process data with
storage efficiency.
4
Relational Data Models Concepts
• Tables − In relational data model, relations are saved in the format of Tables. This format stores
the relation among entities. A table has rows and columns, where rows represents records and
columns represent the attributes.
• Tuple − A single row of a table, which contains a single record for that relation is called a tuple.
• Relation instance − A finite set of tuples in the relational database system represents relation
instance. Relation instances do not have duplicate tuples.
• Relation schema − A relation schema describes the relation name (table name), attributes, and
their names.
• Relation key − Each row has one or more attributes, known as relation key, which can identify
the row in the relation (table) uniquely.
• Attribute domain − Every attribute has some pre-defined value scope, known as attribute
domain.
5
Example: STUDENT Relation
NAME ROLL_NO PHONE_NO ADDRESS AGE
7
Entity-Relationship Data Model
An ER model is the logical representation of data as objects and
relationships among them. These objects are known as entities,
and relationship is an association among these entities. This
model was designed by Peter Chen and published in 1976
papers. It was widely used in database designing. A set of
attributes describe the entities. For example, student_name,
student_id describes the 'student' entity. A set of the same type
of entities is known as an 'Entity set', and the set of the same
type of relationships is known as 'relationship set'.
8
Entity-Relationship Data Model
ER model stands for an Entity-Relationship model. It is a
high-level data model. This model issued to define the
data elements and relationship for a specified system.
It develops a conceptual design for the database. It also
develops a very simple and easy to design view of data.
In ER modeling, the database structure is portrayed as a
diagram called an entity-relationship diagram.
9
Entity-Relationship Data Model
For example, Suppose we design a school database. In this
database, the student will be an entity with attributes like
address, name, id, age, etc. The address can be another
entity with attributes like city, street name, pin code, etc
and there will be a relationship between them.
10
Component of ER Diagram
11
Entity
An entity may be any object, class, person or place. In the
ER diagram, an entity can be represented as rectangles.
Consider an organization as an example- manager,
product, employee, department etc. can be taken as an
entity.
12
Weak Entity
An entity that depends on another entity called a weak
entity. The weak entity doesn't contain any key attribute of
its own. The weak entity is represented by a double
rectangle.
13
Key Attribute
The key attribute is used to represent the main
characteristics of an entity. It represents a primary key. The
key attribute is represented by an ellipse with the text
underlined.
14
Multivalued Attribute
An attribute can have more than one value. These
attributes are known as a multivalued attribute. The
double oval is used to represent multivalued attribute.
For example, a student can have more than one phone
number.
15
Derived Attribute
An attribute that can be derived from other attribute is
known as a derived attribute. It can be represented by a
dashed ellipse.
For example, A person's age changes over time and can be
derived from another attribute like Date of birth.
16
Relationship
A relationship is used to describe the relation between
entities. Diamond or rhombus is used to represent the
relationship.
17
One-to –One Relationship
When only one instance of an entity is associated with the
relationship, then it is known as one to one relationship.
For example, A female can marry to one male, and a male
can marry to one female.
18
Many-to –Many Relationship
When more than one instance of the entity on the left,
and more than one instance of an entity on the right
associates with the relationship then it is known as a
many-to-many relationship.
For example, Employee can assign by many projects and
project can have many employees.
19
ER-Diagram Examples
20
ER-Diagram Examples
21
Hierarchical Model
This concept uses a hierarchical tree structure to organise
the data. The hierarchy begins at the root, which contains
root data, and then grows into a tree as child nodes are
added to the parent node.
22
Network Model
The main difference between this model and the
hierarchical model is that any record can have several
parents in the network model. It uses a graph instead of a
hierarchical tree.
23
Object-based Data Model
An extension of the ER model with notions of functions,
encapsulation, and object identity, as well. This model
supports a rich type system that includes structured and
collection types. Thus, in 1980s, various database systems
following the object-oriented approach were developed.
Here, the objects are nothing but the data carrying its
properties.
24
Semi Structured Data Model
This type of data model is different from the other three data
models (explained above). The semistructured data model
allows the data specifications at places where the individual
data items of the same type may have different attributes
sets. The Extensible Markup Language, also known as XML, is
widely used for representing the semistructured data.
Although XML was initially designed for including the markup
information to the text document, it gains importance
because of its application in the exchange of data.
25
Constraints
• Participation Constraints : Participation Constraints
tell us that the participation in a relationship can
either be total or partial.
• When each entity in an entity set participates in a
relation, it is called Total Participation.
• However, when all entities in the given entity set do
not participate in a relation, it is called Partial
Participation.
Constraints
• Structural Constraints : Structural Constraints are also
called Structural properties of a database management
system (DBMS).
• Cardinality Ratios and Participation Constraints taken
together are called Structural Constraints.
• The name constraints refer to the fact that such
limitations must be imposed on the data, for the DBMS
system to be consistent with the requirements.
The Structural constraints are represented by Min-Max notation. This is a pair of
numbers(m, n) that appear on the connecting line between the entities and their
relationships.
The minimum number of times an entity can appear in a relation is represented by m
whereas, the maximum time it is available is denoted by n. If m is 0 it signifies that the
entity is participating in the relation partially, whereas, if m is either greater than or
equal to 1, it denotes total participation of the entity.
Thank you!!
30