9.data Models Relational Model
9.data Models Relational Model
Database Models
• A model is representation of reality, ‘real world’ objects
events and their association.
Definition:
Data Model can be defined as “An integrated collection of
concepts for describing and manipulating data, relationship
between data and constraints on the data in an organization.”
Database Models
• Purpose of data model:
To represent data and to make the data understandable
1. Tuple
Each row of data is a tuple.
2. Cardinality of a relation
Number of tuple in a relationship is its cardinality
E.g. here cardinality is 4
Relational Model
• Basic Terminology
Attributes --> Emp_code Name Year
Tuple --> 2100 Amar 1
2145 Deep 3
1012 Kumar 2
4521 Singh 6
3. Degree of relationship
Each column in a tuple is called an attribute.
Number of attributes in a relationship is its degree.
E.g. here degree is 3
Relational Model
4. Domain
Domain is set of all values that an attribute may contain.
Exp2: Street name and Surname: both are text but belong to
different domains
Relational Model
5. Body of a relation
Consists of an unordered set of zero or more tuples
6. Keys of a relation
It is a set of one or more columns whose combined values are
unique among all occurrences in a given table.
Basic keys:
a) Primary Key
Is an attribute or set of attributes that possess the property of
uniqueness and irreducibility (no subset should be unique)
Relational Model
Relational Model Properties
Alternative Terms in Relational Model
ER DIAGRAM
• ER model was introduced by Peter Chenn in 1976
• The ER model defines the conceptual (or logical) view
of a database.
• It is used for designing database.
• It works around real-wor ld entities and the relationships
among them
• A database schema in the ER Model can be
represented pictorially as ER diagrams
• An ER diagram maps well into a relational schema.
WHY ER DIAGRAM
ER Modeling Constructs
1. Entity
2. Attribute
3. Relationship
Entity
An Entity is a "thing" or “object" in the real world that is
distinguishable from other objects.
Attribute
Attribute
Attribute Types
• Simple and Composite attributes
• Single-valued and Multi-valued attributes
• Stored and Derived attributes
• Key Attribute
Attribute Types
Composite
Attribute Types
Attribute Types
Derived
Key Attribute
Attribute Type: Example
Relationships
• A Relationship is an association among entities For
example:
1. an employee works_at a department
2. a student enrolls in a course.
• Here, Works_at and Enrolls are called relationships.
• Relationships are represented by diamond-shaped box
Relationships
Relationship Set
A set of relationships of similar ty pe is called relationship
Set
The following relationship set "Enrolls(E1,E2,E3)" depicts:
S1 is enrolled in C2,S2 is enrolled in Cl and S3 is enrolled in
C3
Relationship Descriptive Attribute
Like entities, a relationship too can have attributes . These
attributes are called descriptive attributes
For instance, the depositor relationship set between entity
sets customer and account may have the attribute access-
date
Degree of Relationship
The number of different entity sets participating in a
relationship set is called as degree of a relationship set
1. Unary
2. Binary
3. Ternary
4. N-ary
Degree of Relationship
Unary Relationship:{degr ee = 1)
A unary relationship is only one entity participate in a
relationship, the relationship is ca lled as unary relationship.
1) For example,one person is married to only one
person
Degree of Relationship
Binary Relationship: (degree = 2 )
A binary relationship is when two entities participate in a
relationship, and is the most common relationship degree.
2) For example, Student is enrolled in Course
Degree of Relationship
Represented as
MCQ