Unit-2 Data Models
Unit-2 Data Models
Unit –2
–2
Data Model
Data Model
Entity Relationship model
In 1976, Chen developed the ER or (Entity
Relational Model)
It is a high-level conceptual data model that is useful
in developing a conceptual design for a database.
Entity-Relation model is based on the notion of real-
world entities and the relationship between them.
ER modeling helps you to analyze data requirements
systematically to produce a well-designed database.
It develops a conceptual design for the database. It
also develops a very simple and easy to design view of
data.
What is E-R diagram?
E-R diagram: (Entity-Relationship diagram)
It is graphical (pictorial) representation of database.
It uses different types of symbols to represent
different objects of database.
ER diagram having three main components:
1) Entity
2) Attributes
3) Relationship
Notation used in ER diagram
Entity
Entity: An entity is a person, a place or an object or
anything in real world with its own independent
existence.
Represent by Rectangles box.
Entities of a college database:
• Student Entity Name
• Professor/Faculty
• Courses Symbol
• Department
• Result
• Class
• Subject
Entity Set
Entity Set: It is a set (group) of entities of same type.
Examples:
• All persons having an account in a bank
• All the students studying in a college
• All the professors working in a college
• Set of all accounts in a bank
There are two types of entity set.
(a) Strong entity type
(b) Weak entity type
Strong entity type
The Strong Entity is the one whose existence
does not depend on the existence of any other
entity in a schema. It is denoted by a single
rectangle.
A strong entity always has its
own primary key in the set of attributes that
describes the strong entity. It indicates that
each entity in a strong entity set can be
uniquely identified.
Weak entity type
A Weak entity is the one that depends on its owner
entity i.e. a strong entity for its existence.
Weak entity do not have the primary key instead it
has a partial key that uniquely discriminates the
weak entities.
The primary key of a weak entity is a composite key
formed from the primary key of the strong
entity and partial key of the weak entity.
A weak entity is denoted by the double rectangle.
Weak entity type
Weak entity type
Weak entity set
Weak entity set: An entity set that does not have a primary
key is called weak entity set.
Payment-date
Student Student
Types of Attributes
Single valued Attribute Multi valued Attribute
has single data value have multiple data value
e.g. Rollno, CPI e.g. Phoneno (person may have multiple
phonenos), EmailID
Student Student
Types of Attributes
Stored Attribute Derived Attribute
It’s value is stored manually in It’s value is derived or calculated from
database other attributes
e.g. Birthdate e.g. Age (can be calculated using
current date and birthdate)
Student Student
Key Attributes
This is an attributes of a entity must have a unique
value by which any row can be identified is called as
key attribute of entity.
Example: RollNo for student.
Null Attributes
It does not have a value and can be left blank, it’s
optional can be filled or cannot be.
This is special attribute the value of which is
unknown, unassigned, not applicable or missing.
Example: Apartment_number attribute of address
field applies to address in apartment buildings only
and not to other address like row houses. Hence, an
address of a row house would have NULL for its
Apartment_number attribute.
Descriptive Attributes
Descriptive attributes: Attributes of the relationship is called
descriptive attribute.
Issue
RollNo Name Date BookNo Name
Each and every entity must have one primary key attribute.
Relationship between 2 entities is called binary relationship.
Recursive relationship set
Recursive relationship set: The same entity set participates
in a relationship set more than once then it is called recursive
relationship set.
FacID FName DeptID DName
Post
Customer Loan C3 L3
A B
Teacher Student T3 S3
A B S4
Employee Department E3 D3
A B
E4
Book Student B3 S3
A B B4 S4
C1 L1
C2 L2
Saving_Account Current_Account
Sub Class
2. Generalization and Specialization
1. Generalization
Generalization is the process of generalizing the
entities which contain the properties of all the
generalized entities.
It is a bottom up approach, in which two lower level
entities combine to form a higher level entity.
Generalization is the reverse process of Specialization.
It defines a general entity type from a set of
specialized entity type.
It minimizes the difference between the entities by
identifying the common features.
Generalization and Specialization
Generalization
For Example,
ISA
Address Address
Uses Entity 1
Process of creating an
entity by combining Machinery Relation
various components
of E-R diagram is MID Entity 2
called aggregation.
Draw ER Diagram-
Example
Draw ER Diagram
Example: 1 A publication may be book or an article. Articles are
published in Journals has JID. Publication has title and location.
Book having their publisher_id, title and category. Article includes
title, topic and date. Publication is written by Authors stores
Name, address and mobile number. Publication also belongs to
particular subject which has their SID and names.
Solution:
Step:1 Identify Entities
1.Publication
2.Book
3.Article
4.Journal
5.Subject
6.Author
Draw ER Diagram
Step:2 Identify Attributes
1. Publication (title, location)
2. Book (Publisher_id, Title, Category)
3. Article (Title, Date, Topic)
4. Journal(JID)
5. Subject (SID, Name)
6. Author (Name, Address, Mobile Number)
ISA Has
RoomNo
Indoor Outdoor
Doctor
Has
IPDID OPDID
DrID Dr Name
Medical Record
In the given table, NAME, ROLL_NO, PHONE_NO, ADDRESS, and AGE are the
attributes.