Presentation is loading. Please wait.

Presentation is loading. Please wait.

McGraw-Hill/Irwin The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Access 2002 Lab 4 Working with Multiple Tables.

Similar presentations


Presentation on theme: "McGraw-Hill/Irwin The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Access 2002 Lab 4 Working with Multiple Tables."— Presentation transcript:

1 McGraw-Hill/Irwin The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Access 2002 Lab 4 Working with Multiple Tables

2 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 2 McGraw-Hill/Irwin Objectives 1.Create a table using the Table Wizard. 2.Create an input mask. 3.Create a lookup field. 4.Set required properties. 5.Copy and import data between tables and applications. 6.Add a calculated field to a query. 7.Create a crosstab query. 8.Insert a subdatasheet in a table. 9.Define table relationships and enforce referential integrity. 10.Print a database relationships report.

3 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 3 McGraw-Hill/Irwin Concepts 1.Input Mask - An input mask controls how data is entered in a field of a table, query, or form. 2.Lookup Field - A lookup field provides a list of values from which the user can choose to enter data into that field. 3.Copy and Import - Selections can be copied or duplicated to new locations in a database, between databases, or to other applications or imported from another application and converted into a format that can be used in a table. 4.Required Property - The Required property specifies whether a value is required in a field.

4 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 4 McGraw-Hill/Irwin Concepts 5.Calculated Field - A calculated field displays the result of a calculation in a query. 6.Crosstab Query - A crosstab query summarizes table data and displays it in a tabular format. 7.Subdatasheet - A subdatasheet is a data table nested in another data table that contains data related or joined to the table where it resides. 8.Relationship - A relationship establishes the association between common fields in two tables.

5 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 5 McGraw-Hill/Irwin Outline Creating a Table with the Table Wizard Controlling Field Input –Changing Field Properties –Creating an Input Mask –Creating a Lookup Field

6 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 6 McGraw-Hill/Irwin Outline Copying and Importing Data –Copying Data from Another Table –Importing Data from another Application Making Fields Required Using Calculations in Queries –Creating a Multi-table Query –Adding a Calculated Field

7 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 7 McGraw-Hill/Irwin Outline Creating a Crosstab Query –Using the Crosstab Query Wizard –Refining the Query Design Using Subdatasheets –Inserting a Subdatasheet into a Master Table –Displaying and Printing a Subdatasheet

8 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 8 McGraw-Hill/Irwin Outline Defining Table Relationships –Establishing a One-to-One Relationship –Establishing a One-to-Many Relationship –Enforcing Referential Integrity –Printing a Relationships Report –Backing up and Restoring a Database Lab Review

9 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 9 McGraw-Hill/Irwin Creating a Table with the Table Wizard Helps you create a new data table Leads you step by step through process Can select … –Type or category of table –Table design –Fields Assigns a primary key Creates a related data-entry form

10 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 10 McGraw-Hill/Irwin Table Wizard

11 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 11 McGraw-Hill/Irwin Table Wizard Prompts

12 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 12 McGraw-Hill/Irwin Controlling Field Input Field Properties –Field characteristics, for example … Name Size Data type –Input Mask Controls where data is entered Makes the task of entering data easy –Lookup Values

13 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 13 McGraw-Hill/Irwin Input Mask Access automatically inserts hyphens for a social security number If user enters hyphens, input mask will correct error Social Security Number

14 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 14 McGraw-Hill/Irwin 00-9 must be entered 9Entry not required; if made, must be a digit or space #Entry not required; if made, must be a digit or space, +, or - LA-Z must be entered ?Entry not required; if made, must be a letter from A-Z ALetter or digit must be entered aEntry not required; if made, must be a letter or a digit &Entry required; can be any character, or a space Characters for Input Masks

15 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 15 McGraw-Hill/Irwin CEntry not required; if made, can be any character or a space.,:;-/Decimal placeholder and thousand, date, time separators <Converts entries to lower case >Converts entries to uppercase !Displays input mask from right to left where ! is inserted \Displays the character that follows as a literal character Characters for Input Masks

16 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 16 McGraw-Hill/Irwin Provides a list of values Values can be from … A Lookup List - an existing table A Value List - a fixed set of values that are defined Concept 2: LOOKUP FIELD

17 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 17 McGraw-Hill/Irwin Lookup List An association is created when a lookup field uses an existing table Foreign key – a field in one table that refers to the primary key in another table –Indicates how tables are related –Field names do not have to match –Data types must be the same

18 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 18 McGraw-Hill/Irwin Value List Values entered when lookup field is created Values should be static  Examples - Mr., Mr., or Miss Selected value stored in the record No association to a related table

19 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 19 McGraw-Hill/Irwin Creating a Value List with the Wizard

20 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 20 McGraw-Hill/Irwin Lookup Tab Entry

21 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 21 McGraw-Hill/Irwin To copy - duplicate to another location –New locations in a database –Between databases –To other locations To import - retrieve data that has been saved in another format Concept 3: COPY AND IMPORT

22 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 22 McGraw-Hill/Irwin Copy and Import Source Destination System Clipboard Office Clipboard

23 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 23 McGraw-Hill/Irwin Importing File/Get/External Data/Import Select type of import file Import Spreadsheet Wizard is started

24 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 24 McGraw-Hill/Irwin Importing Data from Another Application

25 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 25 McGraw-Hill/Irwin Value is required in a field Property can be set to yes or no If yes, value cannot be null (zero) Can be set for any type of field except AutoNumber Primary key will not accept null values Concept 4: REQUIRED PROPERTY

26 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 26 McGraw-Hill/Irwin Required Property Set to Yes

27 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 27 McGraw-Hill/Irwin Using Calculations in Queries Create query Select fields Enter expression in design grid Run query

28 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 28 McGraw-Hill/Irwin Displays the results of a calculation Examples Sum of all inventory Average salary for a department Highest sale figures Create your own calculation Use a function Concept 5: CALCULATED FIELD

29 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 29 McGraw-Hill/Irwin Function What it Calculates SumTotals values in a field AverageAverages values in a field CountCounts number of values MinimumFinds lowest value MaximumFinds highest value Standard deviationMeasure of the dispersion of a frequency distribution VarianceSquare of standard deviation Predefined Calculations

30 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 30 McGraw-Hill/Irwin Using a Calculated Field Calculated field formula Calculated gross pay

31 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 31 McGraw-Hill/Irwin Summarizes table data Displays data in a tabular format Field values Calculated by sum, average, and count Grouped along left side and across the top of the datasheet Why are crosstab queries useful? Concept 6: CROSSTAB QUERY

32 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 32 McGraw-Hill/Irwin Using the Crosstab Query Wizard Open the Crosstab Query Wizard Select a table or a query for the crosstab results Select fields to use as row headings –Displayed along left side of data sheet Select fields to use as column headings –Displayed along top of the data sheet Select fields to be calculated and function

33 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 33 McGraw-Hill/Irwin Creating a Crosstab Query Create a regular query –Use to create a crosstab query that will show the average number of hours per employee per week Run query

34 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 34 McGraw-Hill/Irwin Crosstab Query Result Crosstab query result Automatically calculated the average number of hours per employee per week

35 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 35 McGraw-Hill/Irwin Refining the Query Design Rename columns –Change heading to "Average Hours" Move columns –Columns are in date order

36 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 36 McGraw-Hill/Irwin A data table that is nested in another data table Contains data related or joined to the table where it resides Can view and edit data easily Subdatasheet Concept 7: SUBDATASHEET

37 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 37 McGraw-Hill/Irwin Subdatasheet Master table Child fields Master fields

38 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 38 McGraw-Hill/Irwin Creating a Subdatasheet

39 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 39 McGraw-Hill/Irwin Subdatasheet Results

40 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 40 McGraw-Hill/Irwin Establishes the association between common fields in two tables Related fields –Same data type –Contains same kind of information –Can have different field names Concept 8: RELATIONSHIP

41 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 41 McGraw-Hill/Irwin One-to-one One-to-many Many-to-many Can you give examples of each of these relationships? Defining Table Relationships

42 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 42 McGraw-Hill/Irwin Referential Integrity Rules Ensures that relationships are valid Ensures that related data is not accidentally changed or deleted

43 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 43 McGraw-Hill/Irwin Association between two tables Primary key in each record of one table corresponds to the matching value in the related table Establishing a One-to-One Relationship

44 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 44 McGraw-Hill/Irwin Association between two tables Primary key field value in each record corresponds to the value in the matching field of many records in the related table Establishing a One-to-Many Relationship

45 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 45 McGraw-Hill/Irwin Enforcing Referential Integrity An erroneous change to a record in one table could adversely affect its relations Prevent this with referential integrity Once set, warning message displayed if rules broken

46 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 46 McGraw-Hill/Irwin Referential Integrity

47 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 47 McGraw-Hill/Irwin Choose File/Print Relationships –A preview of report is displayed –Database name and creation date are automatically used as the report header. Print report and save for future reference Printing a Relationship Report

48 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 48 McGraw-Hill/Irwin Perform periodic backups –Power outage or system failure –Lost or corrupted file Backup –Saves a copy of the database –Backup programs Windows Explorer My Computer Microsoft Backup Backing up and Restoring a Database

49 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 49 McGraw-Hill/Irwin Restore Operation Copies a backup file from storage medium Use same method to restore as you used to backup Tools/Database Utilities/Compact and Repair Database –Performance enhancement

50 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 50 McGraw-Hill/Irwin Key Terms Backup - Operation that saves a copy of the database or other type of file to a storage medium other than the computer's hard disk. Calculated Field - Field based on information contained in multiple fields of the database, or the results of an expression rather than actual data. Child Field - One or more fields in the embedded subdatasheet that will be linked to master fields in the master table. Copy – To duplicate a selection to another location. Crosstab Query - Summarizes large amounts of data in an easy-to-read, row-and-column format.

51 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 51 McGraw-Hill/Irwin Key Terms Destination – The location where a copied selection is inserted. Expand indicator – The + symbol in a datasheet that indicates a subdatasheet is available. Foreign key - Field in one table that refers to the primary key field in another table and indicates how the tables are related Function - Predefined calculations provided by Access to calculate Sum, average etc Import - To retrieve data that has been saved in another format into an Access table. Input Mask - Used in fields and text boxes to format data and provide control over what values can be entered into a field.

52 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 52 McGraw-Hill/Irwin Key Terms Junction Table - Holds the primary key fields from the other two tables in a many-to-many relationship. Lookup Field - Provides a list of values the user can choose from to enter data into that field. Lookup List - The lookup field that uses another table as the source for values. Many-to-Many – An association between two tables in which one record in either table can relate to many records in other tables. Master Field - Fields from the master table. Master Table - The table that holds the subdatasheet.

53 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 53 McGraw-Hill/Irwin Key Terms Office Clipboard - An Office XP storage area in memory that can store up to 24 items. One-to-Many - An association between two tables in which the primary key field value in each record in the primary table corresponds to the value in the matching field value of one record in the other table. One-to-One - An association between two tables in which each record in the first table contains a field value that corresponds to the field value of one record in the other table. Primary Table - The “one” side of two related tables in a one-to-many relationship. Referential Integrity - A set of rules used by Access to ensure that relationships between tables are valid and that related data is not accidentally changed or deleted.

54 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 54 McGraw-Hill/Irwin Key Terms Relationship - The association between common fields in two tables. Required Property - Specifies whether a value is required in a field. Restore - Operation that copies a backup file from the storage medium back onto the computer's hard disk. Source - The original selection that is copied. Subdatasheet - A data table nested in another data table that contains data related or joined to the table where it resides. System Clipboard - A temporary Windows storage area in memory Value List - The lookup field that fixed values.

55 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 55 McGraw-Hill/Irwin Discussion Questions 1.Discuss the differences between using the Table Wizard and the Design View for creating new data tables. When would you use one as opposed to the other? 2.Discuss the purpose of a crosstab query. When would it be better to use this type of query instead of a simple query?

56 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 56 McGraw-Hill/Irwin Discussion Questions 3.Discuss how input mask and lookup fields can help data entry. To what types of field data could you apply input masks? For what types of data could you create lookup fields? 4.Discuss the purpose of table relationships. When and why should you enforce referential integrity among related tables? Are there any situations where this would be a hindrance rather than a help?

57 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 57 McGraw-Hill/Irwin Frequently Asked Questions What flexibility do I have if I use the Table Wizard to create a table? I need to enter social security numbers in a field and I don't want to enter the dashes. How can input mask help me? Name some of the predefined input masks provided by Access. What is the difference between a lookup list and a value list? Don't they do the same thing?

58 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 58 McGraw-Hill/Irwin Frequently Asked Questions What is the difference between copy and import? How can I ensure that fields are completely filled in for my club employee table? Will Access still accept a record if one of the required field values is missing? Can I do calculations in Access?

59 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 59 McGraw-Hill/Irwin Frequently Asked Questions Can I create my own calculations in Access or do I have to use Access's predefined functions? What is a crosstab query? When would I use one? Is there an easy way to create a crosstab query? How do I create a subdatasheet in Access?

60 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 60 McGraw-Hill/Irwin Frequently Asked Questions How do subdatasheets differ from joined queries? I created a subdatasheet, but I can't see all the data from the other table. How do I display the subdatasheet?

61 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 61 McGraw-Hill/Irwin Frequently Asked Questions What is an Access relationship? Describe the three relationship types. I want to prevent data from being accidentally deleted in my database. What is referential integrity? Can I print a copy of the relationships in my database? When should I run Compact and Repair?

62 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 62 McGraw-Hill/Irwin Web Links Relationships: FMEA –http://www.fmeca.com/ffsoft/productf.htmhttp://www.fmeca.com/ffsoft/productf.htm A3: Referential Intergrity –http://www.athree.com/tables/integrity/http://www.athree.com/tables/integrity/ MS Access Tips –http://wa.apana.org.au/~abrowne/xbase-07.htmlhttp://wa.apana.org.au/~abrowne/xbase-07.html Converting Database Files –http://support.microsoft.com/support/kb/articles /Q286/3/41.ASPhttp://support.microsoft.com/support/kb/articles /Q286/3/41.ASP

63 The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 63 McGraw-Hill/Irwin Web Links Table Relationships –http://water305b.rti.org/concepts.htmlhttp://water305b.rti.org/concepts.html Microsoft Access Developer's Forum –http://www.microsoft.com/accessdev/http://www.microsoft.com/accessdev/ Tek-Tips Forum –http://www.tek- tips.com/gthreadminder.cfm/lev2/4/lev3/27/pid/ 181http://www.tek- tips.com/gthreadminder.cfm/lev2/4/lev3/27/pid/ 181


Download ppt "McGraw-Hill/Irwin The O’Leary Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Access 2002 Lab 4 Working with Multiple Tables."

Similar presentations


Ads by Google