Upload
gaven-farrin
View
218
Download
1
Tags:
Embed Size (px)
Citation preview
Database Modeling
IT Key Ideas, Dynamic Database Systems, 2002
Chapter 8
Location Address Suburb Phone Date Starting TimeClareview School 13 Albert St Clareview 8295 5554 8/3/2002 5:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 9/3/2002 7:00 PMWilliamstown Function Centre 10 Main Way Williamstown 8297 3153 13/3/2002 8:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 15/3/2002 5:30 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 16/3/2002 6:00 PMSulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819 21/3/2002 1:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 23/3/2002 7:30 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 30/3/2002 7:30 PMClareview School 13 Albert St Clareview 8295 5554 5/4/2002 5:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 6/4/2002 7:00 PMSulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819 20/4/2002 1:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 20/4/2002 7:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 27/4/2002 7:00 PMClareview School 13 Albert St Clareview 8295 5554 3/5/2002 6:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 4/5/2002 7:30 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 11/5/2002 6:30 PMClareview School 13 Albert St Clareview 8295 5554 7/6/2002 5:00 PM
Disk Jockey Appointments
IT Key Ideas, Dynamic Database Systems, 2002
1. How is the data ordered?2. Is any of the data repeated?
page 86
Location Address Suburb Phone Date Starting TimeClareview School 13 Albert St Clareview 8295 5554 8/3/2002 5:00 PMClareview School 13 Albert St Clareview 8295 5554 5/4/2002 5:00 PMClareview School 13 Albert St Clareview 8295 5554 3/5/2002 6:00 PMClareview School 13 Albert St Clareview 8295 5554 7/6/2002 5:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 9/3/2002 7:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 23/3/2002 7:30 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 6/4/2002 7:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 20/4/2002 7:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 4/5/2002 7:30 PMSulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819 21/3/2002 1:00 PMSulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819 20/4/2002 1:00 PMWilliamstown Function Centre 10 Main Way Williamstown 8297 3153 13/3/2002 8:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 15/3/2002 5:30 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 16/3/2002 6:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 30/3/2002 7:30 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 27/4/2002 7:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 11/5/2002 6:30 PM
IT Key Ideas, Dynamic Database Systems, 2002
page 86
1. How is the data ordered?
2. Is any of the data repeated?
3. How might it be possible to save time and space?
The second, third, fourth and fifth occurrences of the data shown is redundant.
IT Key Ideas, Dynamic Database Systems, 2002
Mayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367Mayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367Mayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367Mayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367Mayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367
page 87
Location Address Suburb Phone Date Starting TimeClareview School 13 Albert St Clareview 8295 5554 8/3/2002 5:00 PMClareview School 13 Albert St Clareview 8295 5554 5/4/2002 5:00 PMClareview School 13 Albert St Clareview 8295 5554 3/5/2002 6:00 PMClareview School 13 Albert St Clareview 8295 5554 7/6/2002 5:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 9/3/2002 7:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 23/3/2002 7:30 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 6/4/2002 7:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 20/4/2002 7:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 4/5/2002 7:30 PMSulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819 21/3/2002 1:00 PMSulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819 20/4/2002 1:00 PMWilliamstown Function Centre 10 Main Way Williamstown 8297 3153 13/3/2002 8:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 15/3/2002 5:30 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 16/3/2002 6:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 30/3/2002 7:30 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 27/4/2002 7:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 11/5/2002 6:30 PM
redundant data
IT Key Ideas, Dynamic Database Systems, 2002
Location Address Suburb Phone Date Starting TimeClareview School 13 Albert St Clareview 8295 5554 8/3/2002 5:00 PMClareview School 13 Albert St Clareview 8295 5554 5/4/2002 5:00 PMClareview School 13 Albert St Clareview 8295 5554 3/5/2002 6:00 PMClareview School 13 Albert St Clareview 8295 5554 7/6/2002 5:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 9/3/2002 7:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 23/3/2002 7:30 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 6/4/2002 7:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 20/4/2002 7:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 4/5/2002 7:30 PMSulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819 21/3/2002 1:00 PMSulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819 20/4/2002 1:00 PMWilliamstown Function Centre 10 Main Way Williamstown 8297 3153 13/3/2002 8:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 15/3/2002 5:30 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 16/3/2002 6:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 30/3/2002 7:30 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 27/4/2002 7:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 11/5/2002 6:30 PM
IT Key Ideas, Dynamic Database Systems, 2002
What does this data belong to or have in common?
it is all about? the Function Centres
The name is not necessarily straightforwardit might be called Locations or …
Location Address Suburb Phone Date Starting TimeClareview School 13 Albert St Clareview 8295 5554 8/3/2002 5:00 PMClareview School 13 Albert St Clareview 8295 5554 5/4/2002 5:00 PMClareview School 13 Albert St Clareview 8295 5554 3/5/2002 6:00 PMClareview School 13 Albert St Clareview 8295 5554 7/6/2002 5:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 9/3/2002 7:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 23/3/2002 7:30 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 6/4/2002 7:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 20/4/2002 7:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 4/5/2002 7:30 PMSulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819 21/3/2002 1:00 PMSulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819 20/4/2002 1:00 PMWilliamstown Function Centre 10 Main Way Williamstown 8297 3153 13/3/2002 8:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 15/3/2002 5:30 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 16/3/2002 6:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 30/3/2002 7:30 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 27/4/2002 7:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 11/5/2002 6:30 PM
IT Key Ideas, Dynamic Database Systems, 2002
What does this data belong to or have in common?
it is all about?
Appointments
1.x
IT Key Ideas, Dynamic Database Systems, 2002
A relational database system avoids data redundancy by storing the data that belongs to different entities into separate tables.
systems with multiple tables page 87
1.x
IT Key Ideas, Dynamic Database Systems, 2002
An entity according to the dictionary means “a thing” or “a being” or a “creature”.
The taxation office lists an individual, a partnership, an association, a corporation and a company as examples of entities.
Entities
IT Key Ideas, Dynamic Database Systems, 2002
page 87
1.x
IT Key Ideas, Dynamic Database Systems, 2002
A key field is an element of data in a table that uniquely defines a record.
Key fields page 87
which field?
1.x
IT Key Ideas, Dynamic Database Systems, 2002
There will often be different fields that could be set as a key field. Such fields are called candidate keys, as they are just that, candidates for the key field.
Candidate keys page 87
IT Key Ideas, Dynamic Database Systems, 2002
FunctionsLocation Address Suburb Phone
Clareview School 13 Albert St Clareview 8295 5554Clareview School 13 Albert St Clareview 8295 5554Clareview School 13 Albert St Clareview 8295 5554Clareview School 13 Albert St Clareview 8295 5554Mayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367Mayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367Mayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367Mayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367Mayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367Sulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819Sulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819Williamstown Function Centre 10 Main Way Williamstown 8297 3153Zervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696Zervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696Zervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696Zervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696Zervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696
There are several candidate keys for the entity about the functions.
Namely
• the Name of the location• the Address
• the Phone Number
Note:
• the Suburb is not
because two (or more) Function Centres could be in the one suburb
or a new field may be created
eg.
• Location ID
• Location Code
• Function Centre ID
NB: this is the more likely approach at this level
Location Address Suburb Phone Date Starting TimeClareview School 13 Albert St Clareview 8295 5554 8/3/2002 5:00 PMMayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367 5/4/2002 5:00 PMWilliamstown Function Centre 10 Main Way Williamstown 8297 3153 3/5/2002 6:00 PMZervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696 7/6/2002 5:00 PM
9/3/2002 7:00 PM23/3/2002 7:30 PM6/4/2002 7:00 PM
20/4/2002 7:00 PM4/5/2002 7:30 PM
Sulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819 21/3/2002 1:00 PM20/4/2002 1:00 PM13/3/2002 8:00 PM16/3/2002 5:30 PM16/3/2002 6:00 PM30/3/2002 7:30 PM27/4/2002 7:00 PM11/5/2002 6:30 PM
the first four fields form one entity
this data is saved in one table
IT Key Ideas, Dynamic Database Systems, 2002
namely
Function
Centre IDLocation Address Suburb Phone
CS Clareview School 13 Albert St Clareview 8295 5554MFCC Mayer Falls Civic Centre 5 Fifth Ave Mayer Falls 8349 3367WFC Williamstown Function Centre 10 Main Way Williamstown 8297 3153ZVCC Zervaas Valley Civic Centre 6 Regency Tce Zervaas Valley 8270 7696SCS Sulleyvale Combined School 4 Young Lane Sulleyvale 8296 0819
Note: The existence of the Function Centre ID field.
IT Key Ideas, Dynamic Database Systems, 2002
the other fields form a second entity possibly called,
Function Centre
ID Date Starting Time
CS 8/3/2002 5:00 PMMFCC 9/3/2002 7:00 PMWFC 13/3/2002 8:00 PMZVCC 16/3/2002 5:30 PMZVCC 16/3/2002 6:00 PMSCS 21/3/2002 1:00 PMMFCC 23/3/2002 7:30 PMZVCC 30/3/2002 7:30 PMCS 5/4/2002 5:00 PMMFCC 6/4/2002 7:00 PMMFCC 20/4/2002 7:00 PMSCS 20/4/2002 1:00 PMZVCC 27/4/2002 7:00 PMCS 3/5/2002 6:00 PMMFCC 4/5/2002 7:30 PMZVCC 11/5/2002 6:30 PMCS 7/6/2002 5:00 PM
Note: the existence of the Function Centre ID, in order to be able to track where the appointments are.
IT Key Ideas, Dynamic Database Systems, 2002
Appointments
this data is saved in a second table
Relating the tables
page 90
setting a primary key page 90
• select Design View for the Function Centres table
• select the Function Centre ID field
• click on the primary key button on the Toolbar
IT Key Ideas, Dynamic Database Systems, 2002
• save the table
relating the tables page 91
• select the relationship button on the toolbar
IT Key Ideas, Dynamic Database Systems, 2002
• add both tables (use the Shift key) and close
• select the primary key field from the Function Centres table
• drag and drop this field to its matching field in the Appointments table(its foreign key)
Referential Integrity page 91
Data integrity involves ensuring the data is accurate, reliable, appropriate, correct.
IT Key Ideas, Dynamic Database Systems, 2002
Referential integrity involves ensuring that a record in the transaction table does not refer to a source entity that does not exist in the source table.
In this case, making sure that an Appointment is not entered for a non-existent Function Centre.
IT Key Ideas, Dynamic Database Systems, 2002
page 97 Exercise 8.2
Data type, size, defaults, validation
Data Element Type SizeDefault value
(if appropriate)Validation Rule (if appropriate)
Date of Birth Date/Time
Date of Sale Date/Time
Time of Ride Date/Time
Gender Text
Test Percentage Number
Temperature Number
Returned Status Boolean
Booking Date Date/Time
IT Key Ideas, Dynamic Database Systems, 2002
Data type, size, defaults, validation
Year Published Number
Studio Number
Test Status Boolean
Fun Run Time Date/Time
Year of Manufacture Number
Student Vote Number
Ensuite Boolean
Date of Birth Date/Time
Bank Withdrawal Number
IT Key Ideas, Dynamic Database Systems, 2002
page 98 Practical 8.3 Cleaners
IT Key Ideas, Dynamic Database Systems, 2002
Cleaners Data
Dictionaries
Companies Table
Name Type Size FormatCompany ID Text 6Company Text 30Address Text 25Suburb Text 25Phone Number Text 10 @@@@\ @@@@
Fax Number Text 10 @@@@\ @@@@
Contacts Table
Name Type Size FormatContact ID Text 12First Name Text 20Surname Text 25Position Text 30Department Text 30Phone Number Text 10 @@@@\ @@@@
Fax Number Text 10 @@@@\ @@@@
Company ID Text 6
Cleaning Occurrences Table
Name Type Size FormatContact ID Text 25Date Date/Time 8Start Time Date/Time 8Duration Single 4
IT Key Ideas, Dynamic Database Systems, 2002
page 101 Exercise 8.4 Private Detectivepage 102 Exercise 8.5 City Tourspage 103 Exercise 8.6 Video Storepage 104 Exercise 8.7 Chauffeur Service
Chapter 8
********************************
IT Key Ideas, Dynamic Database Systems, 2002