29
2mis6010-L 2mis6010-L Databases and Databases and Spreadsheets Spreadsheets Lecturer Lecturer Nishant Pithia Nishant Pithia

2mis6010-L Databases and Spreadsheets

  • Upload
    sabin

  • View
    30

  • Download
    2

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

Page 1: 2mis6010-L  Databases and Spreadsheets

2mis6010-L 2mis6010-L Databases and SpreadsheetsDatabases and Spreadsheets

LecturerLecturerNishant PithiaNishant Pithia

Page 2: 2mis6010-L  Databases and Spreadsheets

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

Page 3: 2mis6010-L  Databases and Spreadsheets

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. ??????????

??????????

Page 4: 2mis6010-L  Databases and Spreadsheets

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

Page 5: 2mis6010-L  Databases and Spreadsheets

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

Page 6: 2mis6010-L  Databases and Spreadsheets

Cause 1: Set Relationship without Enforcing Referential IntegrityCause 1: Set Relationship without Enforcing Referential Integrity

Page 7: 2mis6010-L  Databases and Spreadsheets

Run Query to Display Anderson’s OrderRun Query to Display Anderson’s Order

Page 8: 2mis6010-L  Databases and Spreadsheets

Cause 1: Cause 1: Referential integrity is not enforcedReferential integrity is not enforced

Where is Anderson???Where is Anderson???

Page 9: 2mis6010-L  Databases and Spreadsheets

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

Page 10: 2mis6010-L  Databases and Spreadsheets

Cause: Unmatched data types between matching fieldsCause: Unmatched data types between matching fields

Page 11: 2mis6010-L  Databases and Spreadsheets

Cause 2: Unmatched data types between matching fieldsCause 2: Unmatched data types between matching fields

Page 12: 2mis6010-L  Databases and Spreadsheets

Enforced Referential integrityEnforced Referential integrity

Page 13: 2mis6010-L  Databases and Spreadsheets

Run Query again ….Still No record!!!!!!!!?????Run Query again ….Still No record!!!!!!!!?????

Page 14: 2mis6010-L  Databases and Spreadsheets

Cause 3: Use inappropriate matching fieldsCause 3: Use inappropriate matching fields

Page 15: 2mis6010-L  Databases and Spreadsheets

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

Page 16: 2mis6010-L  Databases and Spreadsheets
Page 17: 2mis6010-L  Databases and Spreadsheets

Now Query is working!!Now Query is working!!

Page 18: 2mis6010-L  Databases and Spreadsheets

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

Page 19: 2mis6010-L  Databases and Spreadsheets

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?)

Page 20: 2mis6010-L  Databases and Spreadsheets

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

Page 21: 2mis6010-L  Databases and Spreadsheets

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

Page 22: 2mis6010-L  Databases and Spreadsheets
Page 23: 2mis6010-L  Databases and Spreadsheets

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

Page 24: 2mis6010-L  Databases and Spreadsheets
Page 25: 2mis6010-L  Databases and Spreadsheets

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.

Page 26: 2mis6010-L  Databases and Spreadsheets
Page 27: 2mis6010-L  Databases and Spreadsheets

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

Page 28: 2mis6010-L  Databases and Spreadsheets

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

Page 29: 2mis6010-L  Databases and Spreadsheets

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!