Professional Documents
Culture Documents
Schema
• Step 1:
–For each strong entity type in the ER
diagram, create a relation that includes
all the simple attributes of the entity.
• Any composite attribute must be
represented as a basic attribute.
• Omit multi-valued/derived attributes.
• Step 2:
– For each weak entity type create a new
relation.
• Include all the attributes of the weak
entity.
• Add the primary key of the strong entity
(owner entity) as a foreign key.
• The primary key of the weak entity will
be a combination of the key attribute of
the owner entity and the partial key of the
weak entity.
ENO TelNO DNO
FName LName
Employee
ENO FName LName TelNO Salary
Dependent
Partial Key
ENO DNO Relationship
Primary Key
• Step 3:
1 1
Employee Manages Department
# of Employees
FName LName
S.d
ate
Employee
Department
DNO DName StartDate MemNO
• Step 4:
– For 1:M relationships select the many side of the
relation and indicate the primary key of the one
side as the foreign key of the many side.
Lecturer 1 M
Teach Course
Course
CNO CName Duration LNO
´ Step 5:
´ For M:N relationships create a new relation.
´ Contain the primary keys of the two relations and any attributes on the relationship
type.
´ Step 6:
´ For multi-valued attributes create a new relation containing the:
SNO PNO
Qty
M
Supplier Supply N Project
SName
Parts PartNO
Supply
Primary Key
Convert the following ER Diagram to relational
model.
Functional Dependency
´ A functional dependency is a relationship between attributes, such that an attribute
‘B’ is said to be functionally dependent on another attribute ‘A’, if the value of ‘A’ at
all times determines the value of ‘B’.
´ Functional dependency is indicated as:
´ A B {B is functionally dependent on A}
Sylvia Tok 22 East Coast Lane Toys manager 2600 Update anomaly
Eric Wei 100 Jurong drive Toys assistant 2200
manager
? ? ? ? security guard 1500
key
Potential deletion anomaly
Insertion anomaly
EXAMPLE OF AN UPDATE
ANOMALY
Consider the relation:
EMP_PROJ ( Emp#, Proj#, Ename, Pname,
No_hours)
´ Example 1:
´ Emp _Project{ENO, EName {PNO, Hours}}
100 Nimal 7 40
200 Sunil 1 5
EMPLOYEE
ENO EName
EMP-PROJ
FD1
FD2
FD3
• Is in 1NF but not it 2NF.
– Reason:
• The nonprime attribute ENAME violates
2NF because of FD2, as do the nonprime
attributes PNAME and PLOCATION
because of FD3.
– The functional dependencies FD2 and FD3
make ENAME, PNAME and PLOCATION
partially dependent on the primary keys
{SSN, PNUMBER} of EMP-PROJ, thus,
violating the 2NF test.
• If a relation schema is not in 2NF, it can be
“second normalized” or “2NF normalized”
into a number of 2NF relations in which
nonprime attributes are associated only with
the part of the primary key on which they are
fully functionally dependent.
EMP_PROJ
2nd Normalization
EP1
SSN PNUMBER HOURS
EP2
SSN ENAME
EP3
PNUMBER PNAME PLOCATION
Third Normal Form (3NF)
Definition:
• Transitive functional dependency - a FD X -> Z
that can be derived from two FDs X -> Y and
Y -> Z . And Y should not be a candidate key.
Examples:
- SSN -> DMGRSSN is a transitive FD since
SSN -> DNUMBER and DNUMBER ->
DMGRSSN hold
- SSN -> ENAME is non-transitive since there is
no set of attributes X where SSN -> X and
X -> ENAME
EMP_DEPT
3NF Normalization