Professional Documents
Culture Documents
Database Design/Modelling Conceptual Tool: Entity-Relationship (ER) Data Model
Database Design/Modelling Conceptual Tool: Entity-Relationship (ER) Data Model
Database Design/Modelling Conceptual Tool: Entity-Relationship (ER) Data Model
Conceptual Tool
Entity-Relationship(ER) Data Model
1
Entity-Relationship Data Model
What is Entity ? Ram
What is Entity set ?
Ram
Aditya Entity Set (Student)
Annu
An Entity Set do not need to be disjoint.
Entity is represented by set of attributes.
2
Types of attribute
(a) Simple & Composite attributes
Student ------- Name
------- Roll No
------- Branch
Composite
Address
Register
Participation - Total
- Partial
Roles of Entity
• Implicit Explicit
Recursive relationship
Descriptive attributes
5
Types of Entity Sets
Strong Entity Set
Weak Entity Set
Have sufficient
attributes to from a key
6
Steps of ER Analysis & Design
1. Identify Entity, then entity sets
Completely model them, i.e. attributes (types) , Keys etc.
a. One to One ( 1 : 1)
b. One to Many ( 1 : M)
c. Many to One ( M : 1)
d. Many to Many ( M : M )
8
(1) One to One ( 1 : 1)
RAM CO 3405
CO 3402
NEETU CO 2404
CO 2401
ANNU CO 3403
9
(3) Many to One ( 1 : 1)
Associated
Faculty HOD
with
Opt Subject
Student
Subordinate dominant
Entity Entity
Loan_ Pay_no Pay_date
amt
no
Loan Payment
Loan Payment
Total Participation
Partial Participation
11
Keys
1. Super Key
( Custname, Cus-id, DOB)
2. Candidate Key
( Cust_id), ( Custname, DOB)
3. Primary Key
( Custid ) or ( Custname, DOB)
12
Transforming ER Diagram to Tables
1. Tabular representation of strong Entity Sets
Roll_no Address C_id P_Marks
Student Opt
Courses
name Phone
C_name
• For n-ary RS
14
2. Tabular Representation of Weak Entity Set
A Weak
(a1, a2, . . . . an)
discriminator
B Strong
(b1, b2, . . . . bn)
Primary Key (b1, b2)
Two tables
A (a1, a2, . . . . an) U (b1, b2)
B(b1, b2, . . . . bn)
Account Acct
Branch
Branc
Assets
Tab 1 Branch (bname, city, assets)
Tab 2 Account (Acct_no, balance, bname)
16
Tabular Representation of ER Diagram
Multivalued Attribute Case
Emp_no
Employee ---------
Ename
Depatt.
Table Dependent name name
Dependent name ( dname, emp_no)
Composite Attribute Case Employee
Address
17
Extended ER Features
Generalization / Specialization
Acctno Balance
Account
Interest_ Overdraft_
Rate ISA Amount
Saving Checking
Account Account
Tabular Representation
Tab 1 Account (Acctno, balance)
Tab 2 Saving Acct (Acctno, Interest_Rate)
Tab 3 Checking Acct (Acctno, Overdraft_ Amount) 18
Constraints on Generalization
•Disjoint
E.g. Account entity set
•Overlapping
Employee
ISA
Designer Tester
ISA ISA
Disjoint
19
Aggregation
Abstraction through which relationships are treated as higher
level entities.
Job
Work Branch
Emp
on
Aggregated
Entity
ManagesSets
Various Anomalies
- Insertion
- Deletion
- Modification
+
21
Relational Data Model
Introduced by Ted Codd in 1970
Based on the concept of Mathematical relation
Some Important definitions
(represent the terminologies)
(1) A relation schema R
(2) A relation r
(3) Mathematical Definition of relation (r)
r(R) ( dom (A1) X dom (A2) X . . . . X dom (A3) )
22
Relational Data Model
Characteristics of Relations
1. Ordering of tuples in a relation
2. Ordering of values within a tuple
3. Values in the tuples must be atomic
4. Value of a tuple may be null
Relational Data Model ( 3 Parts )
1. Relational Database
2. Relational Rules
3. Relational Operations
23
Relational Data Model
Terminologies
-Relation table
- tuple row
-Attribute column
- Cardinality no. of tuples
-Degree number of attribute or arity
- Domain Set of permitted values
- Primary Key
-Relation Schema
24
Relational Database Design
25
Relational Database Design
-Proposed by Codd (1972)
- Codd
1 NF
2 NF
3 NF ( Stronger definition by Byoce & Codd)
BCNF
4 NF
:
:
-Significance
Reducing redundancy
Eliminate Various types of anomalies
To simplifying the enforcement of certain integrity constraints
26
2 NF Based on Functional Dependency
What is functional Dependency (FD) ?
Definition
A B C D
a1 b1 c1 d1
a1 b2 c1 d2
a2 b2 c2 d2
a2 b3 c2 d3
a3 b3 c2 d4
27
Uses of Functional Dependency
1. F holds on R
2. r satisfying F
30
Rules of Inference (cont..)
(3) Transitivity Rules
if
then holds
( 4) Union Rule
if and
then
( 5) Decomposition Rule
if , then and
35
Canonical Cover Fc
-Minimal set of FDs
-Efforts for testing the FDs are reduced.
- Reduce the size of F without changing its closure, new
set thus formed is Fc.
- Also called as
Irreducible sets of FDs
Or
Minimal sets of FDs
-reduction is done by eliminating extraneous attributes.
36
Algorithm for Fc evaluation
1.Set Fc = F
2.Replace each FD, X A1, A2, . . . . . An in Fc by n FDs.
X A1, X A2, . . . . . . X An
3.For each FD X A in Fc
For each attribute B is an element of X
if (( Fc – {X A}) U {(X - B) A})
is equivalent to Fc then
replace X A with (X - B) A
in Fc
4. For each remaining FDs XA in Fc
If (Fc – {XA}) is equivalent to Fc then remove
XA from Fc
37
Algorithm for Fc evaluation (cont..)
Setp 3
If ((Fc – {X A}) U {(X -B) A} is
equivalent to Fc
Check :----
Let X – {B} = and check if can be
inferred from Fc. To do so, compute +
under F; if + includes all attributes in A
then B is extraneous in X 38
Relational Database Design
Informal design guidline for relation shemas
1. Semantic of the attribute
2. Reducing the redundant values in the tuples.
3. Reducing the null values in the tuples
4. Disallowing the possibility of generating spurious tuples
Various Anomalies
- Insertion
- Deletion
- Modification
+
39
Exercises
Thanks
Any Queries ?
40