Upload
sabin
View
30
Download
2
Tags:
Embed Size (px)
DESCRIPTION
2mis6010-L Databases and Spreadsheets. Lecturer Nishant Pithia. Week 5. Problem-solving and Revision for Database u sing Access Catch-up p ractical session for Week 1 – 4. Workshop 5 for MS Access - Report. Key Highlights from Previous Lectures. Stepwise database design Approach - PowerPoint PPT Presentation
Citation preview
2mis6010-L 2mis6010-L Databases and SpreadsheetsDatabases and Spreadsheets
LecturerLecturerNishant PithiaNishant Pithia
Week 5 Week 5 Problem-solving Problem-solving and Revision forand Revision for Database Database
uusing Accesssing Access
Catch-up Catch-up ppractical session for Week 1 – 4. ractical session for Week 1 – 4.
Workshop 5 for Workshop 5 for MS Access -MS Access - Report Report
Key Highlights from Previous LecturesKey Highlights from Previous Lectures
Stepwise database design ApproachStepwise database design Approach
Simple Entity Relationship Diagram for database designSimple Entity Relationship Diagram for database design Entity; Its Attributes with data typesEntity; Its Attributes with data types Making Assumption for relationship typesMaking Assumption for relationship types
Constrains for Database Design Constrains for Database Design Entity Integrity (unique and non-null)Entity Integrity (unique and non-null) Referential IntegrityReferential Integrity (RI) and FK (RI) and FK
Realise relationship in table view under the Constraints. Realise relationship in table view under the Constraints. ??????????
??????????
Problems from Last WeekProblems from Last Week
Queries last weekQueries last week::
Run query to Join tables for the order Run query to Join tables for the order information of a particular customer (e.g. information of a particular customer (e.g. Anderson)Anderson)
Run query to join multiple tables. Run query to join multiple tables.
ProblemProblem:: Retrieve no data Retrieve no data
Causes of the ProblemCauses of the Problem CausesCauses::
Referential integrity is not enforcedReferential integrity is not enforced
Unmatched data types and properties between Primary Key Unmatched data types and properties between Primary Key (PK) and its corresponding Foreign Key (FK) (PK) and its corresponding Foreign Key (FK)
No value for FK Attributes/Fields, i.e. no matching values No value for FK Attributes/Fields, i.e. no matching values between tablesbetween tables
Use inappropriate matching fields between tables, i.e. even Use inappropriate matching fields between tables, i.e. even set non FK attribute as a matching fieldset non FK attribute as a matching field
ReasonsReasons::
Lack of full understanding of RI and FKLack of full understanding of RI and FK
Cause 1: Set Relationship without Enforcing Referential IntegrityCause 1: Set Relationship without Enforcing Referential Integrity
Run Query to Display Anderson’s OrderRun Query to Display Anderson’s Order
Cause 1: Cause 1: Referential integrity is not enforcedReferential integrity is not enforced
Where is Anderson???Where is Anderson???
Benefit of Enforcing RIBenefit of Enforcing RI
Realize the relationshipRealize the relationship
Set Clear Matching Fields between tablesSet Clear Matching Fields between tables
Automatically Check Matching Records for Automatically Check Matching Records for given relationship given relationship
Cause: Unmatched data types between matching fieldsCause: Unmatched data types between matching fields
Cause 2: Unmatched data types between matching fieldsCause 2: Unmatched data types between matching fields
Enforced Referential integrityEnforced Referential integrity
Run Query again ….Still No record!!!!!!!!?????Run Query again ….Still No record!!!!!!!!?????
Cause 3: Use inappropriate matching fieldsCause 3: Use inappropriate matching fields
Referential Integrity In MS AccessReferential Integrity In MS Access
Referential Integrity
1.1. Matching Fields: FK & PK Matching Fields: FK & PK
2.2. Matching Fields with the same data types Matching Fields with the same data types
3.3. Matching Values between the FieldsMatching Values between the Fields
The values found Under FK in a table The values found Under FK in a table must must be found Under PK in another tablebe found Under PK in another table
ONLYONLY
Now Query is working!!Now Query is working!!
Implications and RemindersImplications and Reminders
Join Query joins tables by:Join Query joins tables by:
1.1. Finding the matching fields between tables Finding the matching fields between tables based on FK and PKbased on FK and PK
2.2. Searching the matching values between the Searching the matching values between the matching fieldsmatching fields
End of Problem-solving End of Problem-solving
Recommended Approach for Assignment 1Recommended Approach for Assignment 1
– Stage 1 Planning– Stage 1 Planning
Stage 1Stage 1: Planning : Planning on paperon paper before entering data before entering data
(i.e. Step 1 and 2 in Lecture 2)(i.e. Step 1 and 2 in Lecture 2)
1.1. Entity and Relationship mapping with clear Entity and Relationship mapping with clear assumptions and understanding of business assumptions and understanding of business cases.cases.
2.2. Check some rules (fan shape connection?)Check some rules (fan shape connection?)
Stage 1: Planning (cont’d) Stage 1: Planning (cont’d)
3.3. Step 3 Step 3 in in the Lecture 2: the Lecture 2: Plan for your tables view with PK and FK Plan for your tables view with PK and FK Make sure:Make sure: the table with PK in one end and the table with PK in one end and
the the table with FK in many endtable with FK in many end
TeamIDTeamID(PK)(PK)
Details
T01 ………
T02 ………..
CoachID(PK)
TeamD(FK)
OtherDetails
C01 T01 ………..
C02 T01 ……
C03 T02 ……
Table with PK Table with FK
Stage 2: From Paper to AccessStage 2: From Paper to Access
Define each table (entity) with primary key, Define each table (entity) with primary key, also foreign Key, other fields with their also foreign Key, other fields with their data types. data types.
Make sure PK and FK have the same data Make sure PK and FK have the same data typestypes and properties and properties
Stage 2: From Paper to Access Stage 2: From Paper to Access (Cont’d)(Cont’d)
Create Relationship between the defined Create Relationship between the defined tablestables
Enforce the referential integrityEnforce the referential integrity
Step 3Step 3
Enter data Enter data to theto the table table with PK with PK in in one end one end first, then first, then to to the the table table with FK inwith FK in many end. many end. Avoid missing valuesAvoid missing values
The values under the FK in a table must The values under the FK in a table must match those for PK in another table. match those for PK in another table.
Additional Notes for Assignment 1Additional Notes for Assignment 1
Tables with clear relationshipsTables with clear relationships
Interrelated tables with FK as the linkInterrelated tables with FK as the link FK and corresponding PK have the same data types FK and corresponding PK have the same data types Referential integrity is enforcedReferential integrity is enforced
Query: make sure joining tables is working fineQuery: make sure joining tables is working fine
Keep Form and Report simple and clear Keep Form and Report simple and clear
Broad Reading for Relational DatabaseBroad Reading for Relational Database
Essential ReadingEssential Reading
Colin Ritchie (2002), Relational Database Colin Ritchie (2002), Relational Database Principle, 2nd Edition, Thomas Learning.Principle, 2nd Edition, Thomas Learning.
More books in LibraryMore books in Library
Week 6 – 10 Week 6 – 10 Practical sessions on Ms ExcelPractical sessions on Ms Excel
Lectures by RequestLectures by Request
Reminders: Reminders: 77thth December 2005 December 2005 (Week 9) Deadline for (Week 9) Deadline for
DB Assignment!!!DB Assignment!!! Catch UP!!Catch UP!! Problems??? Problems??? Drop in and see me!Drop in and see me!