Presentation is loading. Please wait.

Presentation is loading. Please wait.

U:/msu/course/cse/103 Day 18, Slide 1 CSE 103 Day 18 If you are not enrolled in CSE 103, please save and log out by 10:10.

Similar presentations


Presentation on theme: "U:/msu/course/cse/103 Day 18, Slide 1 CSE 103 Day 18 If you are not enrolled in CSE 103, please save and log out by 10:10."— Presentation transcript:

1 http://www.cse.msu.edu/~cse103 U:/msu/course/cse/103 Day 18, Slide 1 CSE 103 Day 18 If you are not enrolled in CSE 103, please save and log out by 10:10. Students: –Finish MegaCorp import (if logged in)! –Today: Last day of Access! –Review Day 12 in the textbook

2 http://www.cse.msu.edu/~cse103 U:/msu/course/cse/103 Day 18, Slide 2 Review of Day 17 Homework Queries Create a list of suite descriptions with the accompanying product descriptions, quantities and number in stock. (qry_hw11_suiteMakeup) [42] Modify this query to also list the color name of each product and to order the list by suite. (qry_hw11_suite&color) [still 42!]

3 http://www.cse.msu.edu/~cse103 U:/msu/course/cse/103 Day 18, Slide 3 Redundancy and Consistency See pages 1-17 and 1-18, as well as pages 12-2 and 12-3. –What is Data Redundancy? How can it be controlled? –What is Data Consistency? How can it be assured? –What is Entity Integrity? How can it be enforced in Access? –What is Referential Integrity?

4 http://www.cse.msu.edu/~cse103 U:/msu/course/cse/103 Day 18, Slide 4 Referential Integrity in Access In MegaCorp, choose Tools -> Relationships Right-click, Show Table: Products and Colors Create a relationship like you would a join: by dragging a line to connect fields –One should be the primary key of a table! Access asks if you want to enforce integrity, and if you want to use Cascade Update/Delete –Cascade Update: When a primary key changes, copy the new value to the related foreign key –Cascade Delete: When a record with a primary key value is deleted, also delete all records having that value in a related foreign key field

5 http://www.cse.msu.edu/~cse103 U:/msu/course/cse/103 Day 18, Slide 5 MegaCorp Relationships Use the relationship window to create relationships between tables in the MegaCorp database –When would you want Cascade Update or Cascade Delete? –When would you not? Field names do not have to match to make a relationship, but datatypes must match –Autonumber matches with Number (not Auto)

6 http://www.cse.msu.edu/~cse103 U:/msu/course/cse/103 Day 18, Slide 6 Problems in music-day08 db These questions are "what if" only. Some of these could damage your database, so do not actually change your data! What would happen if you were to change MP3 to MP4 in the DigitalFormat field of the DigitalTracks table? Why? What would happen if you were to delete the Elektra/Asylum row from the Labels table? Why?

7 http://www.cse.msu.edu/~cse103 U:/msu/course/cse/103 Day 18, Slide 7 Relationships in music-day08 Create relationships and try to enforce referential integrity in your music-day08 database –Don't create one for Secondary Artist What problems do you run into? –Read any error messages carefully, then investigate the table or tables that have the problem. How could we solve this?

8 http://www.cse.msu.edu/~cse103 U:/msu/course/cse/103 Day 18, Slide 8 Lookup Fields Have we solved the problem illustrated by: –What would happen if you were to change MP3 to MP4 in the DigitalFormat field of the DigitalTracks table? Lookup Fields can restrict field values (See Access 2000 HELP on how to define and use) –Makes data entry in Datasheet view much easier Fix the problem in the Labels and Albums tables, then change the Label field in tbl_Albums into a Lookup Field

9 http://www.cse.msu.edu/~cse103 U:/msu/course/cse/103 Day 18, Slide 9 contacts DB Relationships Define relationships in your contacts db Enforce referential integrity in these relationships Add a table tbl_PhoneTypes to restrict the possible types of phones Allow only these types in the related field in tbl_PhoneNumbers –Could you write a quick query to find all the different PhoneTypes from that field?

10 http://www.cse.msu.edu/~cse103 U:/msu/course/cse/103 Day 18, Slide 10 Homework Click on the Homework link on today’s classwork page to find out what must be done before taking the 2.5 BT Highlights: –Add and use tbl_AddressTypes in contacts db –Add more lookup fields in MegaCorp db –Queries on tables with lookup fields –After the BT we will begin working on dynamic Web pages. Review basic HTML from CSE 101, Days 6-7 (use the101 Web site).

11 http://www.cse.msu.edu/~cse103 U:/msu/course/cse/103 Day 18, Slide 11 Bridge Task 2.5 Covers all materials from Day 15 through and including Day 18 –Design, design, and more design Datatypes and primary keys Adding a new table or tables to an existing database Designing a multiple-table database Relationships and referential integrity Lookup fields Review text, Web and homework Bring books, notes, back-up disk, photo ID, etc. Practice BT is available –Answer to design problem will be in course AFS space

12 http://www.cse.msu.edu/~cse103 U:/msu/course/cse/103 Day 18, Slide 12 Homework you must have done before the BT 2.5 Contacts: –15 records in tbl_People –Phones and Addresses N:M relationships (2 tables each + “Types” table makes 3) –Email 1:N relationship (1 table) –Referential Integrity enforced on all relationships MegaCorp: –All data imported –Referential Integrity enforced –Lookup fields


Download ppt "U:/msu/course/cse/103 Day 18, Slide 1 CSE 103 Day 18 If you are not enrolled in CSE 103, please save and log out by 10:10."

Similar presentations


Ads by Google