44220: Database Design & Implementation Implementing Physical Domains Ian Perry Room: C49 Tel Ext.:
Ian PerrySlide : 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 Student 1MNM
Ian PerrySlide : Database Design & Implementation: Implementing Physical Domains Domains Schema SSC Domains StaffIdentifiers = ; StudentIdentifiers = ; Titles = Mr, Ms, Mrs, Dr; PersonNames = String, <= 12 Characters; CourseIdentifiers = ; CourseNames = Computing, Law, …, Marketing; CourseDurations = 3, 6, 9, 12; OLevelPoints = ; ScalePoints = 1 - 6; PayRates = £13,000, £13,500, …, £15,500; BirthDates = Date, >= 21 Years before Today;
Ian PerrySlide : 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 PerrySlide : 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 PerrySlide : 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 Size Validation Rule Input Mask Key Fields => Relationships
Ian PerrySlide : Database Design & Implementation: Implementing Physical Domains Physical Implementation
Ian PerrySlide : 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 PerrySlide : 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; whole numbers between –2,147,483,648 and 2,147,483,647. Single; large numbers, both positive & negative, including fractions. Double; very large numbers, both positive & negative, including fractions.
Ian PerrySlide : Database Design & Implementation: Implementing Physical Domains Data Type & Field Size Text from 1 to 255 characters (Default = 50). 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 65,535 characters.
Ian PerrySlide : Database Design & Implementation: Implementing Physical Domains Data Type & Format Date/Time can accommodate Date and Time values between the Years 100 and 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 PerrySlide : 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 PerrySlide : 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 = ; 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 PerrySlide : 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 PerrySlide : 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 PerrySlide : 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 PerrySlide : 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 PerrySlide : 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.