Staffordshire UNIVERSITY School of Computing Dr. Andy Seddon From data model to database.
-
Upload
magdalene-shields -
Category
Documents
-
view
213 -
download
0
Transcript of Staffordshire UNIVERSITY School of Computing Dr. Andy Seddon From data model to database.
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
From data model to database
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
Mapping the ERD onto a database
Rules for assigning attributes to relations
Relations must be well-normalised– No repeating groups– Every determinant in a relation must
be a candidate identifier of that relation
Where there is a choice, avoid relations where attributes will have null values
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
1:1 relationships - total participation (1)
Create a single relation
Department( Dept#, Dept_Name, Faculty, Head)
Department HeadHas a1 1
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
1:1 relationships - total participation (2)
Dept# Dept_Name Faculty Head
10 History A Jones
20 Sociology B Smith
30 Maths C Edwards
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
1:1 relationships - membership of one entity
partial (1)PILOTS is a list of available pilots who do not have to take weekly flights
Create two relations
‘Post’ pilot number to Weekly Flights relation
WeeklyFlight
Pilot1 1
Has a
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
1:1 relationships - membership of one entity
partial (2)Weekly Flights
Pilots
Flight# Date of Dep. Pilot#
BA123 22-Oct-96 P10DL567 24-Oct-96 P20
Pilot# Pilot Name Address
P10 James Address_AP15 MacDonald Address_BP20 Green Address_C
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
1:M relationship - total participation (1)
Create two relations
‘Post’ department number to employees relation(Also appropriate for situation where ‘1’ entity type is partial - eg when department has no employees)
Department EmployeeHas1 M
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
1:M relationship - total participation (2)
Department
Employees
Dept# Dept Name Location
1 History Arts2 English Arts3 Geography Geog
Emp# Emp Name Date of Appt Dept#
100 Lee 9/75 1200 Smith 10/80 1300 Adams 1/80 3400 Sharma 3/90 2
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
1:M relationship ‘many’ entity type partial (1)
Employees do not have to belong to a department
Create a new relation to record relationships
Department Employee1 M
Has
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
1:M relationship ‘many’ entity type partial (2)
Department
Employees
Dept# Dept Name Location
1 History Arts2 English Arts3 Geography Geog
Emp# Emp Name Date of Appt
100 Lee 9/75200 Smith 10/80300 Adams 1/80400 Sharma 3/90500 Jones 1/87
Emp# Dept#
100 1200 1300 3400 2
Emp_Dept
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
M:N relationship (1)
Create a new relation to record the relationship
Appropriate for both types of participation on either ‘side’
Student ModuleM N
Take
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
M:N relationship (2)
Students
Student_Modules
Stud# Stud Name DOB
1 Lee 19722 Smith 19743 Adams 19734 Sharma 1972
Mod# Stud# Year Grade
cm103-5 1 1996 Ccm506-1 1 1996 Ecm506-1 2 1995 Bcm780-3 3 1996 Bcm103-5 4 1997 A
Mod# Module Name
cm103-5 PSADcm206-6 DBMScm506-1 IBIScm780-3 SDM
Modules
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
Mapping Supertypes/Subtypes onto
a database (1)
Can be mapped onto a database in two ways
Under-graduate
Post-graduate
d
Student
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
Mapping Supertypes/Subtypes onto
a database (2)Either:Student( Stud#, Stud_Name, DOB, DOE,
Student_Type)Undergrad( Stud#, Module#, Year, Grade)Postgrad( Stud#, Degree, Thesis_Title)
ORUndergrad( Stud#, Stud_Name, DOB, DOE, Module#,
Year, Grade)Postgrad( Stud#, Stud_Name, DOB, DOE, Degree,
Thesis_Title)
StaffordshireUNIVERSITY
Schoolof
Computing
Dr. Andy Seddon
Summary
Draw up enterprise rules– interviews– questionnaires etc.
Construct E-R model and ERD Map E-R model onto database i.e. write
database schema Check relations are in BCNF If not, create new relations which are in
BCNF