1. 1.5 Data Modeling:
• The process of analysis of data and their relationships to other
data objects is known as data modeling.
• It defines how data is connected to each other and how they are
processed and stored inside the system.
• A data model provides a way to describe the design of a database
at the physical, logical, and view levels.
• Underlying the structure of a database is the data model: a
collection of conceptual tools for describing data, data
relationships, data semantics, and consistency constraints.
Mrs. Ujjwala Sachin Patil (SITCOE)
2. Types of data Model:
1. Record Based Logical Model:
• Relational data Model
• Network Model
• Hierarchical Model
2. E-R Model(Entity Relationship Model)
Mrs. Ujjwala Sachin Patil (SITCOE)
3. 1.Record based Logical Model:
i. Relational Model:
• Relational model is called as record based logical model because the
database is structured in fixed format of different types.
• The relational model uses a collection of tables to represent both data
and the relationships among those data.
• Each table has multiple columns, and each column has a unique name.
• Tables are also known as relations.
• The columns of the table correspond to the attributes of the record type.
• The relational data model is the most widely used data model, and a vast
majority of current database systems are based on the relational model.
• This model is simple and it has all the properties and capabilities
required to process data with storage efficiency.
Mrs. Ujjwala Sachin Patil (SITCOE)
4. • 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.
Mrs. Ujjwala Sachin Patil (SITCOE)
5. Relational Model represents how data is stored in Relational
Databases. A relational database stores data in the form of relations
(tables). Consider a relation STUDENT with attributes ROLL_NO,
NAME, ADDRESS, PHONE and AGE shown in Table below.
ROLL_NO NAME ADDRESS PHONE AGE
1 RAM DELHI 9455123451 18
2 RAMESH GURGAON 9652431543 18
3 SUJIT ROHTAK 9156253131 20
4 SURESH DELHI 18
Tuple
Attributes/ columns
Mrs. Ujjwala Sachin Patil (SITCOE)
6. ii. Network Model:
This is an extension of the Hierarchical model. In this model data is
organized more like a graph, and are allowed to have more than one
parent node (many-to-many relationship)
In this database model data is more related as more relationships
are established in this database model.
Mrs. Ujjwala Sachin Patil (SITCOE)
7. iii. Hierarchical Model:
In hierarchical model, data is organized into tree-like structure with
one one-to-many relationship between two different types of data.
This structure allows repeating information using parent and child
relationships.
In this structure parents can have many children but child can have
only one parent.
for example, one department can have many courses, many
professors and of-course many students.
Mrs. Ujjwala Sachin Patil (SITCOE)
9. 1.6 Data Model Using E-R Model:
• The Entity Relationship(ER) model was originally proposed by
Peter in 1976. E-R model is a way to combine network and
relational database ideas.
• In short ER model is a conceptual data model than views the real
world as entities and relationships.
• This diagram is mainly used to represent data objects in the
pictorial or visual form.
• The main advantage of the entity relationship model is that, when
once it is drawn it can be easily converted into relation or
relational model. The construction done in ER model can easily be
transformed into relational tables.
Mrs. Ujjwala Sachin Patil (SITCOE)
10. ER Model is based on −
• Entities and their attributes.
• Relationships among entities.
• Entity-Relationship (ER) Model is based on the notion of real-
world entities and relationships among them. While formulating
real-world scenario into the database model, the ER Model creates
entity set, relationship set, general attributes and constraints.
• ER Model is best used for the conceptual design of a database.
Mrs. Ujjwala Sachin Patil (SITCOE)
11. Entity and Relationship:
• Entity − An entity in an ER Model is a real-world entity having
properties called attributes. Every attribute is defined by its set
of values called domain. For example, in a school database, a
student is considered as an entity. Student has various attributes
like name, age, class, etc.
• Relationship − The logical association among entities is
called relationship. Relationships are mapped with entities in
various ways. Mapping cardinalities define the number of
association between two entities.
Mrs. Ujjwala Sachin Patil (SITCOE)
12. Mapping cardinalities −
• one to one
• one to many
• many to one
• many to many
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.
Mrs. Ujjwala Sachin Patil (SITCOE)
13. One-to-one − One entity from entity set A can be
associated with at most one entity of entity set B and vice
versa.
Mrs. Ujjwala Sachin Patil (SITCOE)
14. 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.
Mrs. Ujjwala Sachin Patil (SITCOE)
15. 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.
Mrs. Ujjwala Sachin Patil (SITCOE)
16. Many-to-many − One entity from A can be associated with
more than one entity from B and vice versa.
Mrs. Ujjwala Sachin Patil (SITCOE)
17. Strong and Weak Entity Set:
Strong Entity Set:
The strong entity has a primary key. Weak entities are dependent on
strong entity. Its existence is not dependent on any other entity.
Strong Entity is represented by a single rectangle:
Mrs. Ujjwala Sachin Patil (SITCOE)
18. Weak Entity
A weak entity is an entity that depends on the existence of another
entity. In other words it can not be identified by itself. It uses
foreign key combined with its attributed to form the primary key.
The weak entity in DBMS do not have a primary key and are
dependent on the parent entity. It mainly depends on other entities.
Weak Entity is represented by double rectangle:
Mrs. Ujjwala Sachin Patil (SITCOE)
19. Example of Strong and Weak Entity
The example of strong and weak entity can be understood by the
below figure.
The Strong Entity is Professor, whereas Dependent is a Weak
Entity.
ID is the primary key (represented with a line) and Name
in Dependent entity is called Partial Key (represented with a
dotted line).
Mrs. Ujjwala Sachin Patil (SITCOE)
20. Relationship:
Relationships are represented by diamond-shaped box. Name of the
relationship is written inside the diamond-box. All the entities
(rectangles) participating in a relationship, are connected to it by a
line.
Binary Relationship and Cardinality
A relationship where two entities are participating is called
a binary relationship. Cardinality is the number of instance of an
entity from a relation that can be associated with the relation.
One-to-one
One-to-many
Many-to-one
Many-to-many
Mrs. Ujjwala Sachin Patil (SITCOE)
21. One-to-one − When only one instance of an entity is
associated with the relationship, it is marked as '1:1'. The
following image reflects that only one instance of each
entity should be associated with the relationship. It depicts
one-to-one relationship.
Mrs. Ujjwala Sachin Patil (SITCOE)
22. One-to-many − When more than one instance of an entity is
associated with a relationship, it is marked as '1:N'. The
following image reflects that only one instance of entity on
the left and more than one instance of an entity on the
right can be associated with the relationship. It depicts
one-to-many relationship.
Mrs. Ujjwala Sachin Patil (SITCOE)
23. Many-to-one − When more than one instance of entity is
associated with the relationship, it is marked as 'N:1'. The
following image reflects that more than one instance of an
entity on the left and only one instance of an entity on the
right can be associated with the relationship. It depicts
many-to-one relationship.
Mrs. Ujjwala Sachin Patil (SITCOE)
24. Many-to-many − The following image reflects that more
than one instance of an entity on the left and more than
one instance of an entity on the right can be associated
with the relationship. It depicts many-to-many relationship.
Mrs. Ujjwala Sachin Patil (SITCOE)
25. Attributes:
Attributes are the properties of entities. Attributes are represented
by means of ellipses. Every ellipse represents one attribute and is
directly connected to its entity (rectangle).
Attributes
Mrs. Ujjwala Sachin Patil (SITCOE)
27. 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.
Composite attribute − Composite attributes are made of more than
one simple attribute. For example, a student's complete name may
have first_name and last_name.
If the attributes are composite, they are further divided in a tree like
structure. Every node is then connected to its attribute. That is,
composite attributes are represented by ellipses that are connected
with an ellipse.
e.g.
Mrs. Ujjwala Sachin Patil (SITCOE)
28. 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. For another example, age can be
derived from data_of_birth.
Derived attributes are depicted by dashed ellipse.
Mrs. Ujjwala Sachin Patil (SITCOE)
29. Single-value attribute − Single-value attributes contain single
value. For example − Social_Security_Number.
Multi-value attribute − Multi-value attributes may contain more
than one values. For example, a person can have more than one
phone number, email_address, etc.
Multivalued attributes are depicted by double ellipse.
Mrs. Ujjwala Sachin Patil (SITCOE)