44220: Database Design & Implementation
Implementing Physical Domains
Ian PerryRoom: C41C Tel Ext.: 7287
E-mail: [email protected]
http://itsy.co.uk/ac/0708/sem2/44220_DDI/
Ian Perry Slide 244220: Database Design & Implementation: Implementing Physical Domains
The SSC Database
Relations Staff (StaffID, FirstName, SurName, ScalePoint, DOB) Student (EnrolNo, FirstName, SurName, OLevelPoints,
Tutor) Course (CourseCode, Name, Duration) Team (CourseCode, StaffID) Pay (ScalePoint, RateOfPay)
ER Diagram
Staff Course Student1 MN M
Ian Perry Slide 344220: Database Design & Implementation: Implementing Physical Domains
Domains Schema SSC Domains
StaffIdentifiers = 1001 - 1199; StudentIdentifiers = 2000 - 9999; Titles = Mr, Ms, Mrs, Dr; PersonNames = String, <= 12 Characters; CourseIdentifiers = 101 - 110; CourseNames = Computing, Law, …,
Marketing; CourseDurations = 3, 6, 9, 12; OLevelPoints = 0 - 240; ScalePoints = 1 - 6; PayRates = £13,000, £13,500, …, £15,500; BirthDates = Date, >= 21 Years before
Today;
Ian Perry Slide 444220: Database Design & Implementation: Implementing Physical Domains
Relations – Staff & Student Relation Staff
StaffID: StaffIdentifiers; Title: Titles; FirstName: PersonNames; SurName: PersonNames; ScalePoint: ScalePoints; DOB: BirthDates;
Primary Key: StaffID Foreign Key: ScalePoint refs
Pay.ScalePoint
Relation Student EnrolNo: StudentIdentifiers; Title: Titles; FirstName: PersonNames; SurName: PersonNames; OLevelPoints: OLevelPoints; Tutor: StaffIdentifiers;
Primary Key: EnrolNo Foreign Key: Tutor refs Staff.StaffID
Ian Perry Slide 544220: Database Design & Implementation: Implementing Physical Domains
Relations – Course, Team & Pay
Relation Course CourseCode: CourseIdentifiers; Name: CourseNames; Duration: CourseDurations;
Primary Key: CourseCode
Relation Team CourseCode: CourseIdentifiers; StaffID: StaffIdentifiers;
Primary Key: CourseCode & Staff-ID Foreign Key: CourseCode refs
Course.CourseCode Foreign Key: StaffID refs Staff.StaffID
Relation Pay ScalePoint: ScalePoints; RateOfPay: PayRates;
Primary Key: ScalePoint
Ian Perry Slide 644220: Database Design & Implementation: Implementing Physical Domains
Logical => Physical Translating a Logical Model (e.g. a
Database Schema) into a Physical Model (e.g. an Access Database) requires the following: Schema => Database Relations => Tables Attributes => Field Names Domains => Data Type
Field SizeValidation RuleInput Mask
Key Fields => Relationships
Ian Perry Slide 744220: Database Design & Implementation: Implementing Physical Domains
Physical Implementation - 1
Ian Perry Slide 844220: Database Design & Implementation: Implementing Physical Domains
Physical Implementation - 2
The ‘Team’ Table has composite Primary Key, consisting of BOTH;
CourseCode & StaffID You MUST set up relationships between ALL of the Tables of your
Database, with referential integrity enforced, BEFORE you; ADD any DATA to your Tables, BUILD any QUERIES to answer Questions.
Ian Perry Slide 944220: Database Design & Implementation: Implementing Physical Domains
Controlling Data Entry Access provides 4 main ways to control the
data that can be entered into individual fields. Data Type
Number, Text, Memo, Date/Time, Currency, etc. Field Size (or Format)
depends upon the Data Type chosen. Validation Rule
to control the range of allowable values that can be entered into a field.
Input Mask to force the data that is entered to conform to a
particular shape/pattern.
Ian Perry Slide 1044220: Database Design & Implementation: Implementing Physical Domains
Data Type & Field Size Number
Default = Long Integer; However, ALWAYS store numbers using the smallest
possible Field Size. Byte;
whole numbers, positive only, between 0 and 255. Integer;
whole numbers between –32,768 and 32,767. Long Integer (Default);
whole numbers between –2,147,483,648 and 2,147,483,647.
Single; large numbers, both positive & negative, including
decimal places. Double;
very large numbers, both positive & negative, including decimal places.
Ian Perry Slide 1144220: Database Design & Implementation: Implementing Physical Domains
Data Type & Field Size Text
from 1 to 255 characters (Default = 255).
Domain PersonNames = String, <= 12 Characters;
Attribute FirstName: PersonNames;
Field Definition Field Name :- FirstName Data Type :- Text Field Size :- 12
Memo Field Size cannot be altered, but can
accommodate up to 63,999 characters.
Ian Perry Slide 1244220: Database Design & Implementation: Implementing Physical Domains
Data Type & Format Date/Time
can accommodate Date and Time values between the Years 100 and 9999.
NB. Format ‘decides’ how a Date is displayed. Domain
BirthDates = Date, >= 21 Years before Today;
Attribute DOB: BirthDates;
Field Definition Field Name :- DOB Data Type :- Date/Time Format :- Long Date
Ian Perry Slide 1344220: Database Design & Implementation: Implementing Physical Domains
Data Type & Format Currency
As with Date/Time fields, Format ‘decides’ how Currency fields are displayed.
Domain PayRates = £13,000, £13,500, …, £15,500;
Attribute RateOfPay: PayRates;
Field Definition Field Name :- RateOfPay Data Type :- Currency Format :- Currency
Ian Perry Slide 1444220: Database Design & Implementation: Implementing Physical Domains
Validation Rules To control the range of allowable values
that can be entered into a field. e.g. Numeric Ranges
Domain StaffIdentifiers = 1001 - 1199;
Attribute StaffID: StaffIdentifiers;
Field Definition Field Name :- StaffID Data Type :- Number Field Size :- Integer Validation Rule :- >=1001 And <=1199 Validation Text :- Must be > 1000 And < 1200
Ian Perry Slide 1544220: Database Design & Implementation: Implementing Physical Domains
Validation Rules e.g. Specific Numbers
Domain CourseDurations = 3, 6, 9, 12;
Attribute Duration: CourseDurations;
Field Definition Field Name :- Duration Data Type :- Number Field Size :- Byte Validation Rule :- 3 Or 6 Or 9 Or 12 Validation Text :- 3, 6, 9 or 12 months
only.
Ian Perry Slide 1644220: Database Design & Implementation: Implementing Physical Domains
Validation Rules e.g. Patterns of Text
Domain Titles = Mr, Ms, Mrs, Dr;
Attribute Title: Titles;
Field Definition Field Name :- Title Data Type :- Text Field Size :- 3 Validation Rule :- “Mr” Or “Ms” Or “Mrs” Or
“Dr” Validation Text :- Mr, Ms, Mrs or Dr only.
Ian Perry Slide 1744220: Database Design & Implementation: Implementing Physical Domains
Input Masks To force the data that is entered to
conform to a particular shape/pattern. Domain
PersonNames = String, <= 12 Characters;
Attribute SurName: PersonNames;
Field Definition Field Name :- SurName Data Type :- Text Field Size :- 12 Input Mask :- >L<L??????????
Ian Perry Slide 1844220: Database Design & Implementation: Implementing Physical Domains
A little bit of Everything! Always attempt to constrain the domain
of each Field in as many ways as possible: Domain
Titles = Mr, Ms, Mrs, Dr; Attribute
Title: Titles; Field Definition
Field Name :- Title Data Type :- Text Field Size :- 3 Input Mask :- >L<L? Validation Rule :- “Mr” Or “Ms” Or “Mrs” Or “Dr” Validation Text :- Mr, Ms, Mrs or Dr only.
Ian Perry Slide 1944220: Database Design & Implementation: Implementing Physical Domains
This Week’s Workshop Implementing Physical Domains
in Microsoft Access: Data Types Field Sizes Input Masks Validation Rules
Remember: I will be looking carefully for evidence of
you attempting to use all of the above, when judging the quality of the Implementation of your Database for Assignment 2.
Ian Perry Slide 2044220: Database Design & Implementation: Implementing Physical Domains
The Next 4 Weeks There will be NO Lecture or Workshop
sessions next week! I have to attend a meeting at the Hull Campus.
The Final Lecture will take place; Thursday, the 24th of April.
There will be two more Assignment 2 Support workshops, i.e.; Thursday, the 24th of April. Thursday, the 1st of May.
The Assignment 2 Deadline is; Thursday, the 8th of May.