0% found this document useful (0 votes)
14 views

Unit 3

Here are the types of attributes in E-R diagram: 1. Simple Attribute 2. Composite Attribute Simple Attribute cannot be divided into sub attributes. Composite Attribute can be divided into sub attributes. Examples of simple attribute are Employee ID. Examples of composite attribute are Name (first name, middle name, last name) and Address (street, road, city).

Uploaded by

ss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Unit 3

Here are the types of attributes in E-R diagram: 1. Simple Attribute 2. Composite Attribute Simple Attribute cannot be divided into sub attributes. Composite Attribute can be divided into sub attributes. Examples of simple attribute are Employee ID. Examples of composite attribute are Name (first name, middle name, last name) and Address (street, road, city).

Uploaded by

ss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 41

Database Management System (303105203)

Unit – 3: Database Models


Shreya Dholariya,
Assistant Professor, Computer Science & Engineering
 Basic concepts
 Integrity constraints
 Database models
 E-R diagrams
 Mapping cardinality
 Participation Constraints
 Weak entity set
 Specialization
 Generalization
 Aggregation
 E-R Diagram Example
 Database design involves understanding operational
and business needs of an organization, modeling the
specified requirements, and realizing the
requirements using a database.

 The overall database design process has to follow a


Basic series of steps. The systematic process of designing
Concepts a database is known as design methodology.

 The goal of designing a database is to produce


efficient, high quality, and minimum cost database.

 In large organizations, database administrator


(DBA) is responsible for designing an efficient
database system
 Integrity constraints are the set of rules imposed on
database to maintain quality of data.

 Integrity constraints ensures that any manipulation


on data does not affect the data integrity.

Integrity  It secures the data management.


Constraint
 Various Integrity Constraints are:
1. Check
2. Not null
3. Unique Key
4. Primary key
5. Foreign key
1. Check
 This constraint is defined on a column of the table.
 Limits the data values of variables to a specific set
of values based on condition.
 The constraint can be applied for a single column
Integrity or a group of columns.
Constraint  E.g. amount must be greater than 500.

2. Not null
 This constraint ensures that each column of all the
rows in the table has some value (data).
 Any column value cannot be NULL (empty).
3. Unique Key
 Ensures that the data in each row for a single or
group of columns is unique (distinct).
 A column can have NULL values, but cannot be
duplicated.
Integrity  E.g. Roll Number of a student is Unique.
Constraint
4. Primary Key
 Ensures that a column or a group of columns
identify uniquely each row in the table.
 A column cannot have NULL values and cannot be
duplicated.
 E.g. Roll Number of a student is Unique.
5. Foreign Key
 Also known as Referential Integrity Constraint
 Allows a table to refer a column of another table
with Primary Key
 For e.g. Primary Key
Integrity Student (sroll, sname, std)
Constraint Result (sroll, m1, m2, m3, result)

Foreign Key referring to sroll


column of Student table
 A database model describes the logical structure of a
database.
 It describes whether how a data can be stored,
accessed and updated.
 The most popular example of a database model is
Relational Model
Database  Types of Database Model are:
Models
1. Hierarchical Model
2. Network Model
3. Relational Model
4. Object Oriented Model
5. Entity Relationship Model
In this, the data is organized into a tree-like structure,
where each record has a single parent or root.

Department

Database
Models Manager Worker
(Hierarchical
Model)  The data is organised into tree-like structure with
one data component connected to many other data
components.
 For example, one department can have many
managers and many workers.
In this, the data is organized into a tree-like structure,
where each record can have multiple parents or roots.

A
Database
Models B C
(Network
Model)
D E F

 The data is organised into tree-like structure more


than one data components connected to more than
one other data components.
 In this, the data is stored in the table known as
Relation.

Database  A Relation contain Rows known as Tuples and


Models column known as Attributes
(Relational Employee Relation
Model) Eid Employee Name Salary Attributes
1 Raj 21

2 Meet 22

Tuples
Object oriented data model is based upon real world
situations.

Objects: The real world components and situations are


represented as objects
Database
Attributes and Method:
Models Every object has certain characteristics. These are
(Object Oriented represented using Attributes. The behavior of the
Model) objects is represented using Methods.

Class: Similar attributes and methods are grouped


together using a class. An object can be called as an
instance of the class.
Inheritance: A new class can be derived from the original
class. The derived class contains attributes and methods
of the original class as well as its own.
For E.g.
Database
 Shape, Circle, Rectangle and
Models Triangle are all classes in this
(Object Oriented model. 
 Shape has methods as
Model) GetArea() and GetPerimeter()
 Circle has the attributes Center
and Radius.
 Rectangle has the attributes
Length and Breath
 Triangle has the attributes Base
and Height.
 The Circle, Rectangle and
Triangle classes inherit from the
class Shape.
Stands for Entity-Relationship diagram.

E-R Diagram It is a graphical or a pictorial representation of a


database.

It uses different types of symbols to represent various


instances of database
An entity is a “thing” or “object” in the real
world that is distinguishable from all other
objects.

E-R Diagram For example, each Employee in a firm is an


(Entity) entity.

An entity has a set of properties, and the


values for some set of properties may
uniquely identify an entity.
An entity is represented by a rectangle which
contains the name of an entity.
Entity Symbol
Name

E-R Diagram
(Entity) Employee Example

1. Write down the different entities of college database.


2. Write down the different entities of hotel database.
 It is a collection of different entities of same type.
E-R Diagram Examples:
(Entity Set)  All the employees working in a firm
 All persons having an account in a bank
 All the students studying in a school
 Each entity is described by a set of
attributes/properties. In short, Attributes define
details of Entity
 An attribute is represented by an oval containing
name of an attribute.
E-R Diagram  For e.g., Employee ID and Name are the attributes
(Attributes) of Employee.
Attribute Employee Id Name
Name

Employee
Symbol Example

1. Write down the different attributes of college database.


2. Write down the different attributes of hotel database.
Simple Attribute Composite Attribute
Cannot be divided into sub Can be divided into sub
attributes attributes
E.g. Employee ID E.g. Name
(first name, middle name, last
name)
E-R Diagram Address
(Types of Symbol Symbol (street, road, city)
Name
Attributes) First Last
Employee ID
name name
Middle
name
Single-Valued Attribute Multi-Valued Attribute
Can have only 1 value Can have multiple values

E.g. Employee ID E.g. Phone Number


(Can have more than 1 phone
numbers)
E-R Diagram Address
(Types of Symbol Symbol (street, road, city)

Attributes)
Employee ID
Phone Number
Derived Attributes
It’s value is derived or
calculated from other
attributes.
E-R Diagram For e.g. Age of a person can be
easily known from his/her
(Types of birthdate
Attributes) Symbol:

Age
Middle
Name
First Name Last
Name
Single
Simple
Value
ID Name Composite Apartment

E-R Diagram Derived Composite

(Attributes Age Employee Address Street

Example) Multiple
Value Phone
Birth Date Area
No

1. Create E-R Diagram for college database. Use all types of Attributes
2. Create E-R Diagram for hotel database. Use all types of Attributes
 Relationship is link between several entities.
 It must be placed between two entities and a line
linking it to an entity.
 A relationship is represented by a diamond
containing relationship details.
E-R Diagram  A Relationship between 2 Entities is called Binary
(Relationship Relationship and A Relationship between 3 Entities
is called Ternary Relationship.
Set)
Example
Relationship
Student
Detail

Symbol

Book Issue
 It defined number of entities of one entity set
connected to number of entities of another entity
set using a relationship set.

 Mapping cardinalities are most useful in describing


binary relationship sets.
Mapping
Cardinality  The mapping cardinality are of following types:
1. One to One
2. One to Many
3. Many to One
4. Many to Many
An entity in entity set A is associated with at most one
entity in entity set B, and an entity in entity set B is
associated with at most one entity in entity set A.

Mapping
Cardinality
(One to One)
Set A Set B
For e.g. One Customer is
connected with only one
Loan and One Loan is
customer borrow loan
connected to only One
Customer using Borrow
Relationship Set.
An entity in entity set A is associated with any number
(more than 1) of entities in entity set B. An entity in
entity set B is associated with at only one entity in entity
set A.

Mapping
Cardinality
(One to Many)
Set A Set B
One Customer is
For e.g. connected with more
than one Loan; but, One
customer borrow loan
Loan is connected to only
One Customer using
Borrow Relationship Set.
An entity in entity set A is associated with only one
entity in entity set B. An entity in entity set B is
associated with more than one entities in entity set A.

Mapping
Cardinality
(Many to One)
Set A Set B
One Loan is connected to
For e.g. more than one
Customers; but, One
customer borrow loan Customer is connected
with only one Loan using
Borrow Relationship Set.
More than one entities in entity set A is associated with
more than one entities in entity set B. More than one
entities in entity set B is associated with more than one
entities in entity set A.
Mapping
Cardinality
(Many to
Many)
Set A Set B One Loan is connected to
For e.g. more than one Customers
and One Customer is
customer borrow loan connected with more
than one Loan using
Borrow Relationship Set.
It specifies the participation of an entity set in a
relationship set.
There are two types participation constraints:

 Total participation:
every entity in the entity set participates in at least
Participation one relationship in the relationship set. It is
Constraints denoted by Double Line

 Partial participation
some entities in the entity set may not participate in
any relationship in the relationship set. It is denoted
by Single Line
Partial Participation Total Participation

customer borrow loan

Participation C1 L1
Constraints C2 L2
(Example) C3

Customers Loan
 An entity set that does not have a primary key is
called weak entity set.
 It is denoted by double rectangle symbol.
 When a weak entity set is connected with strong
entity set by some relation, then the relation is
known as Weak Relationship Set.
Weak Entity  It is denoted by Double Diamond.
Set  A Discriminator in Weak Entity Set distinguishes all
other entities.
 It is denoted by Dashed Line
 To make Relationship stronger, the Primary Key is
created by combining Discriminator of Weak Entity
Set and Primary Key of Strong Entity Set.
Discriminator
Payment-date

amount Payment-
loan-no payment-no
amount

loan L_P payment

Weak Entity
Strong Weak Entity Weak Entity
Set (Example) Entity Set Relationship Set

 In the above example, the relationship can be made stronger by


creating Primary Key by combining Discriminator of Weak Entity Set
and Primary Key of Strong Entity Set.

 In above e.g. payment-no (Discriminator) & loan-no (Primary Key)


combines to generate Composite Primary Key as
(loan-no, payment-no)
 The process of creating sub-groups within an entity
is called specialization.

 Top-Down design process; designate subgroupings


Extended E-R within an entity set that are distinctive from other
Diagram : entities in the set.
Specialization  The process of taking a subset of higher level entity
set to form a lower level entity set.

 Uses a triangle component labeled as “ISA”


Specialization
(Example)
 The process of creating a main group from different
entities is called generalization.

 Bottom-Up design process; combine a number of


entity sets that share the same features into a
Extended E-R higher-level entity set.
Diagram :
Generalization  The process of combining two or more low level
entity sets to generate high level entity set.

 Uses a triangle component labeled as “ISA”


Generalization
(Example)
Created Single Entity
“Customer”

Customer
Company

Employee Works Department


Customer
Aggregation Can not connect two relationship

Borrow Borrow

Loan Loan

This process of merging various entities into one single


entity is called Aggregation.
Name Hold EmpID
Customer
Attribute Relationship Primary Key
Entity
Attribute

Payment Age PhoneNo PymtID


Derived Discriminating
Weak Multi Valued
Attribute Attribute
Entity Attribute

E-R Diagram Issue ISA E R


(Summary) Weak Entity
Specialization/ Total
Relationship Participation
Generalization

E R E E R E

One to One One to Many

E R E E R E
Many to One Many to Many
E-R Diagram
(Example)
Draw E-R Diagram for the following:
1) Hospital Management
2) School Management
3) Library Management
E-R Diagram 4) Hotel Management
(Home Work) 5) Bus/Airline/Train Reservation

Tips for Examination:


 Define minimum 4 entities with at least 4 attributes.
 Provide all types of attributes somewhere in any of the
entities
 Show weak entity set, few mapping cardinalities.
Thanks

You might also like