University of Sunderland COMM2Q Unit 2
COMM2QCOMM2QLecture 2Lecture 2
HIS Application BuildingHIS Application Building
University of Sunderland COMM2Q Unit 2
2
An Introduction toAn Introduction to
Relational Data Relational Data AnalysisAnalysis
(Normalisation)(Normalisation)
University of Sunderland COMM2Q Unit 2
3
Steps in NormalisationSteps in Normalisation
1.1. Un-normalised formUn-normalised form
2.2. First Normal FormFirst Normal Form
3.3. Second Normal FormSecond Normal Form
4.4. Third Normal FormThird Normal Form
Relational Data AnalysisRelational Data Analysis
University of Sunderland COMM2Q Unit 2
Relational Data AnalysisRelational Data AnalysisStudent Results TableStudent Results Table
CourseCode
CourseTitle
StudentCode
StudentName
Date ofBirth
TutorCode
TutorName
Grade Result
SYA SystemsAnalysis
A2345A7423B3472A3472B9843
SmithBarkerGreenHarrisGreen
20/08/6903/04/5923/02/7017/07/6910/11/68
17461746133017461330
JonesJonesJarvisJonesJarvis
ACDFB
Dist.PassPassFailMerit
COB COBOL A7423A4217B8238
BarkerMorrisCarter
03/04/6917/01/6809/12/69
152015201520
HooperHooperHooper
EBC
FailMeritPass
PAS Pascal A4217B9843A3393A4247
MorrisGreenWhiteCross
17/01/6810/11/6830/09/6925/12/69
1520128312831520
HooperTrotterTrotterHooper
ABEC
Dist.MeritFailPass
University of Sunderland COMM2Q Unit 2
Relational Data AnalysisRelational Data Analysis
Possible Entities in SystemPossible Entities in System
• COURSECOURSE
• STUDENTSTUDENT
• TUTORTUTOR
• GRADE?GRADE?
University of Sunderland COMM2Q Unit 2
Relational Data AnalysisRelational Data Analysis
Unnormalised Form:Unnormalised Form:
• Table made up of ROWS and Table made up of ROWS and COLUMNSCOLUMNS
• Rows grouped togetherRows grouped together
• Write table in unnormalised formWrite table in unnormalised form
• Choose unique KEY and underlineChoose unique KEY and underline
University of Sunderland COMM2Q Unit 2
Relational Data AnalysisRelational Data Analysis
Data AttributesData Attributes• Student CodeStudent Code• Student NameStudent Name• Date of BirthDate of Birth
• All REPEAT for a given value of COURSE CODE
• Tutor CodeTutor Code• Tutor NameTutor Name• GradeGrade• ResultResult
University of Sunderland COMM2Q Unit 2
8
UNF UNF 1NF 2NF 3NFLEVEL
Course Code 1Course Title 1
Student Code 2Student Name 2Date of Birth 2Tutor Code 2Tutor Name 2Grade 2Result 2
Relational Data AnalysisRelational Data Analysis
Normalisation TableNormalisation Table
University of Sunderland COMM2Q Unit 2
9
• Any relation is in First Normal Form Any relation is in First Normal Form when it contains no repeating groups when it contains no repeating groups of dataof data
Relational Data AnalysisRelational Data Analysis
First Normal FormFirst Normal Form
University of Sunderland COMM2Q Unit 2
10
UNF UNF 1NF 2NF 3NFLEVEL
Course Code 1 Course Code Course Title 1 Course Title
Student Code 2Student Name 2 Course CodeDate of Birth 2 Student CodeTutor Code 2 Student NameTutor Name 2 Date of BirthGrade 2 Tutor CodeResult 2 Tutor Name
GradeResult
Relational Data AnalysisRelational Data Analysis
Normalisation TableNormalisation Table
University of Sunderland COMM2Q Unit 2
11
Relational Data AnalysisRelational Data AnalysisNormalisation TableNormalisation Table
UNF UNF 1NF2NF 3NF LEVEL
Course Code 1 Course CodeCourse Title 1 Course Title
Student Code 2Student Name 2Date of Birth 2Tutor Code 2 Course CodeTutor Name 2 Student CodeGrade 2 Student NameResult 2 Date of Birth
Tutor CodeTutor NameGradeResult
University of Sunderland COMM2Q Unit 2
12
Relational Data AnalysisRelational Data Analysis
Normalisation TableNormalisation Table
UNF UNF 1NF 2NF3NF
LEVEL
Course Code 1 Course CodeCourse Title 1 Course Title
Student Code 2Student Name 2Date of Birth 2Tutor Code 2 Course CodeTutor Name 2 Student CodeGrade 2 Student NameResult 2 Date of Birth
Tutor CodeTutor NameGradeResult
University of Sunderland COMM2Q Unit 2
13
Relational Data AnalysisRelational Data Analysis
Normalisation TableNormalisation Table
UNF UNF 1NF 2NF3NF
LEVEL
Course Code 1 Course CodeCourse Title 1 Course Title
Student Code 2Student Name 2Date of Birth 2Tutor Code 2 Course CodeTutor Name 2 Student CodeGrade 2 Student NameResult 2 Date of Birth
Tutor CodeTutor NameGradeResult
University of Sunderland COMM2Q Unit 2
14
• Any relation already in 1NF is also in Any relation already in 1NF is also in 2NF if EITHER the key is a single 2NF if EITHER the key is a single attribute OR the non-key items are attribute OR the non-key items are fully dependent on the WHOLE keyfully dependent on the WHOLE key
• In Second Normal Form, you remove In Second Normal Form, you remove data items which depend on only data items which depend on only part of a keypart of a key
Relational Data AnalysisRelational Data Analysis
Second Normal FormSecond Normal Form
University of Sunderland COMM2Q Unit 2
Relational Data AnalysisRelational Data Analysis
Student CodeStudent Code Student NameStudent Name
Student CodeStudent Code
Tutor CodeTutor Code
Course CodeCourse Code
University of Sunderland COMM2Q Unit 2
Relational Data AnalysisRelational Data Analysis
Student Name
Date of Birth
Course Code Tutor Code
Student Code Tutor Name
Grade
Result
University of Sunderland COMM2Q Unit 2
17
UNF UNF 1NF2NF 3NF LEVEL
Course Code 1 Course Code Course CodeCourse Title 1 Course Title Course Title
Student Code 2Student Name 2 Course Code Course
CodeDate of Birth 2 Student Code
Student CodeTutor Code 2 Student Name Tutor CodeTutor Name 2 Date of Birth
Tutor NameGrade 2 Tutor Code GradeResult 2 Tutor Name Result
GradeResult
Student CodeStudent
NameDate of
Birth
Relational Data AnalysisRelational Data Analysis
Normalisation Table - 2NFNormalisation Table - 2NF
University of Sunderland COMM2Q Unit 2
18
• Any relation in 2NF is also 3NF if all Any relation in 2NF is also 3NF if all non-key attributes are independent non-key attributes are independent of all other non-key attributes and all of all other non-key attributes and all key attributes are independent of all key attributes are independent of all the other key attributesthe other key attributes
• In Third Normal Form, you remove In Third Normal Form, you remove any attributes which are not directly any attributes which are not directly dependentdependent upon the keyupon the key
Relational Data AnalysisRelational Data Analysis
Third Normal FormThird Normal Form
University of Sunderland COMM2Q Unit 2
19
UNF UNF 1NF 2NF3NF
LEVEL
Course Code 1 Course Code Course CodeCourse Code
Course Title 1 Course Title Course TitleCourse Title
Student Code 2Student Name 2 Course Code Course Code
Course CodeDate of Birth 2 Student Code Student
Code Student CodeTutor Code 2 Student Name Tutor Code
Tutor CodeTutor Name 2 Date of Birth Tutor
Name GradeGrade 2 Tutor Code Grade
Result 2 Tutor Name ResultStudent Code
GradeStudent Name
Result Student Code Date of Birth
Student NameDate of Birth
Tutor Code
Tutor Name
Grade
Result
Relational Data AnalysisRelational Data AnalysisNormalisation Table - 3NFNormalisation Table - 3NF
University of Sunderland COMM2Q Unit 2
20
UNF UNF 1NF2NF 3NF
LEVEL
Course Code 1 Course Code Course CodeCourse Code
Course Title 1 Course Title Course TitleCourse Title
Student Code 2Student Name 2 Course Code Course Code
Course CodeDate of Birth 2 Student Code Student
Code Student CodeTutor Code 2 Student Name Tutor Code
*Tutor CodeTutor Name 2 Date of Birth Tutor
Name *GradeGrade 2 Tutor Code Grade
Result 2 Tutor Name ResultStudent Code
GradeStudent Name
Result Student CodeDate of Birth
Student NameDate of Birth
Tutor Code
Tutor Name
Grade
Result
Relational Data AnalysisRelational Data AnalysisNormalisation Table - 3NF
Foreign key
University of Sunderland COMM2Q Unit 2
Relational Data AnalysisRelational Data Analysis
Summary:Summary:• Choose a suitable key from a table of raw dataChoose a suitable key from a table of raw data• Identify repeating groupsIdentify repeating groups• Write the data in unnormalised formWrite the data in unnormalised form• Convert unnormalised data to first normal formConvert unnormalised data to first normal form• Convert first normal form to second normal Convert first normal form to second normal
formform• Convert second normal form to third normal Convert second normal form to third normal
formform
University of Sunderland COMM2Q Unit 2
NormalisationNormalisation
Constructing a Data Model from 3NF
University of Sunderland COMM2Q Unit 2
UNF UNF 1NF2NF 3NF
LEVEL
Course Code 1 Course Code Course CodeCourse Code
Course Title 1 Course Title Course TitleCourse Title
Student Code 2Student Name 2 Course Code Course Code
Course CodeDate of Birth 2 Student Code Student
Code Student CodeTutor Code 2 Student Name Tutor Code
*Tutor CodeTutor Name 2 Date of Birth Tutor
Name *GradeGrade 2 Tutor Code Grade
Result 2 Tutor Name ResultStudent Code
GradeStudent Name
Result Student CodeDate of Birth
Student NameDate of Birth
Tutor Code
Tutor Name
Grade
Result
Normalisation Table - 3NF
Foreign key
University of Sunderland COMM2Q Unit 2
Student Results Student Results RelationsRelations
COURSE
Course CodeCourse Title
COURSE-STUDENT
Course CodeStudent CodeTutor CodeGrade
STUDENT
Student CodeStudent NameDate of Birth
TUTOR
Tutor CodeTutor Name
GRADE
GradeResult
University of Sunderland COMM2Q Unit 2
Create an entity type for each data relation e.g.
COURSE
Course Code
COURSE-STUDENT
Course CodeStudent Code*Tutor Code*Grade
University of Sunderland COMM2Q Unit 2
Make compound key relations into details
refers to master / detail relationshipCOURSE STUDENT
COURSE-STUDENT
Course CodeStudent Code
Course Code Student Code
University of Sunderland COMM2Q Unit 2
Make relations with foreign keys into detailsCOURSE STUDENT
COURSE-STUDENT
Course CodeStudent Code*Tutor Code*Grade
Course Code Student Code
TUTOR GRADETutor Code Grade
University of Sunderland COMM2Q Unit 2
Redrawn Entity ModelRedrawn Entity Model
COURSE STUDENT
COURSE-STUDENT
Course CodeStudent Code*Tutor Code*Grade
Course Code Student Code
TUTOR GRADETutor Code Grade
University of Sunderland COMM2Q Unit 2
Example 2Example 2
COURSE
Course CodeCourse Title
COURSE-STUDENT
Course CodeStudent Code
STUDENT
Student CodeStudent Name
RESULT
Student Code(Course Code)(Ass. Number)Ass. Mark
ASSIGNMENT
(Course Code)(Ass. Number)Ass. Subject
University of Sunderland COMM2Q Unit 2
Rule 1Rule 1
Create an entity type for each data relation e.g.
COURSE
Course Code
COURSE-STUDENT
Course CodeStudent Code
University of Sunderland COMM2Q Unit 2
Rule 2Rule 2Mark the qualifying elements of
hierarchic keys as a foreign key
• hierarchic key in this example
ASSIGNMENT
*(Course Code) (Ass. Number)
Rule 2
Note: ENTIRE key must be hierarchic
University of Sunderland COMM2Q Unit 2
Rule 3Rule 3Check that all masters of compound
key relations are present
This example has two compound keys
• one made from simple key and hierarchic key
• one made from two simple keysCOURSE-STUDENT
Course CodeStudent Code
RESULT
Student Code(Course Code)(Ass. Number)
University of Sunderland COMM2Q Unit 2
Rule 4Rule 4
Make compound key relations into details
refers to master / detail relationshipCOURSE STUDENT
COURSE-STUDENT
Course CodeStudent Code
Course Code Student Code
University of Sunderland COMM2Q Unit 2
Rule 4Rule 4
Make compound key relations into details
refers to master / detail relationship
COURSE STUDENT
COURSE-STUDENT
Course CodeStudent Code
Course Code Student Code
ASSIGNMENT
RESULT
*(Course Code) (Ass. Number)
Student Code(Course Code)(Ass. Number)
Rule 4 Rule 4Rule 4
University of Sunderland COMM2Q Unit 2
Rule 5Rule 5
COURSE
STUDENT
COURSE-STUDENTCourse Code
Student Code
Course Code
Student Code
ASSIGNMENT
RESULT
*(Course Code) (Ass. Number)
Student Code(Course Code)(Ass. Number)
Make relations with foreign keys into details
Rule 5
Rule 2
University of Sunderland COMM2Q Unit 2
3NF Model3NF Model
COURSE
STUDENT
COURSE-STUDENT
Course CodeStudent Code
Course Code
Student Code
ASSIGNMENT
RESULT
*(Course Code) (Ass. Number)
Student Code(Course Code)(Ass. Number)
Rule 4 Rule 4Rule 4
Rule 5
Rule 2
Top Related