access ch02 more skills12.qxd 5/22/08 10:30 am page 1

6
An index stores the location of records based on the values in a field. An index improves performance when the field is searched or sorted. A one-to-one relationship is a relationship where each record in one table can have only one corresponding record in the other table. In both tables, the field that relates the two tables must contain a unique value. Cypress Sun Resorts needs to store the employee passwords in a separate table to improve database security. To complete this database, you will need the following file: a02_Employee_Logons You will save your files as: a02_Employee_Logons_Your_Name a02_Employee_Logons_Snip_Your_Name 1. Start Access, and then open a02_Employee_Logons. Save the database in your Access Chapter 2 folder as a02_Employee_Logons_Your_Name If the Security Warning bar displays, enable the content. 2. In the Navigation Pane, right-click the Employees table, and then in the shortcut menu, click Design View. Access CHAPTER 2 Copyright © 2009 by Pearson Education, Inc. All rights reserved. From Skills for Success with Microsoft® Office 2007 by Kris Townsend Microsoft Access | Chapter 2 - Building a Relational Database and Creating Forms More Skills: SKILL 12 | Page 1 of 6 More Skills 12 Create Indexes and Establish a One-to-One Relationship

Upload: others

Post on 01-Jan-2022

0 views

Category:

Documents


0 download

TRANSCRIPT

� An index stores the location of records based on the values in a field. An index improves performance when the field is searched or sorted.

� A one-to-one relationship is a relationship where each record in one table can have only onecorresponding record in the other table. In both tables, the field that relates the two tables mustcontain a unique value.

� Cypress Sun Resorts needs to store the employee passwords in a separate table to improvedatabase security.

To complete this database, you will need the following file:� a02_Employee_Logons

You will save your files as:� a02_Employee_Logons_Your_Name� a02_Employee_Logons_Snip_Your_Name

1. Start Access, and then open a02_Employee_Logons. Save the database in your AccessChapter 2 folder as a02_Employee_Logons_Your_Name If the Security Warning bar displays,enable the content.

2. In the Navigation Pane, right-click the Employees table, and then in the shortcut menu,click Design View.

AccessCHAPTER 2

Copyright © 2009 by Pearson Education, Inc. All rights reserved.From Skills for Success with Microsoft® Office 2007 by Kris Townsend

Microsoft Access | Chapter 2 - Building a Relational Database and Creating Forms More Skills: SKILL 12 | Page 1 of 6

More Skills 12 Create Indexes and Establish a One-to-OneRelationship

Access CH02 More Skills12.qxd 5/22/08 10:30 AM Page 1

4. Click the displayed Indexed arrow, and then click Yes (Duplicates OK)

5. Save the table, and then switch to Datasheet view. In the first record, change Mary toyour first name and Bilger to your last name. Click in any other record, and then compareyour screen with Figure 2.

The Last Name index was updated after you finished updating the first record. Thisindex will improve performance whenever the Last Name field is searched or sorted.

Notice that the second and third records contain the same last name—Shields. Becauseemployees may have identical last names, the index allows duplicate values.

Copyright © 2009 by Pearson Education, Inc. All rights reserved.From Skills for Success with Microsoft® Office 2007 by Kris Townsend

Microsoft Access | Chapter 2 - Building a Relational Database and Creating Forms More Skills: SKILL 12 | Page 2 of 6

Last Name Indexedproperty set to No

Figure 1

3. Click in the Last Name field, and then under Field Properties, click the Indexed box.Compare your screen with Figure 1.

The Last Name field does not have an index. By default, only a table’s primary key andany foreign keys used to create relationships have indexes.

Access CH02 More Skills12.qxd 5/22/08 10:30 AM Page 2

6. Switch to Design view, and then click in the User Name field. Click the Indexed box, andthen click the displayed Indexed arrow. In the displayed menu, click Yes (No Duplicates).

Each employee must have a unique user name. Thus, the index will not allow duplicatevalues. The table’s primary key has its own index that does not allow duplicate values.

7. Click Save , and then Close the table. Open the Employee Logons table in Datasheetview. Compare your screen with Figure 3.

Each employee’s logon—a user name and password used to obtain access to secureservices—displays in the datasheet.

Copyright © 2009 by Pearson Education, Inc. All rights reserved.From Skills for Success with Microsoft® Office 2007 by Kris Townsend

Microsoft Access | Chapter 2 - Building a Relational Database and Creating Forms More Skills: SKILL 12 | Page 3 of 6

Duplicate last name values

First record edited

Employee logons

Figure 2

Figure 3

Access CH02 More Skills12.qxd 5/22/08 10:30 AM Page 3

15. Click Save , and then Close the Relationships window. Open the Employees table inDatasheet view.

16. To the left of the first record, click the Expand button , and then compare your screenwith Figure 5.

The related logon for the record with your name displays in a subdatasheet. Asubdatasheet is a datasheet that displays the corresponding records from a relatedtable. Here, the logon for the first record displays. Because the User Name field is com-mon to both tables, the field displays in the datasheet, and it does not display in thesubdatasheet.

Copyright © 2009 by Pearson Education, Inc. All rights reserved.From Skills for Success with Microsoft® Office 2007 by Kris Townsend

Microsoft Access | Chapter 2 - Building a Relational Database and Creating Forms More Skills: SKILL 12 | Page 4 of 6

One-to-one relationship

Figure 4

8. Switch to Design view, and then click in the Password field. Under Field Properties, clickin the Input Mask field, and then click the displayed Build button .

9. In the displayed Input Mask Wizard, click Password, and then click Finish.

10. Click Save , and then switch to Datasheet view. Notice that the values in the Passwordfield are now masked by the asterisk (*) character.

11. Close the table. Display the Database Tools tab, and then in the Show/Hide group,click Relationships.

12. In the displayed Show Table dialog box, double-click Employees, and then double-clickEmployee Logons. Close the Show Table dialog box.

13. In the Employees table displayed in the Relationships window, drag the User Name field tothe User Name field in the Employee Logons table. When the pointer displays, releasethe mouse button.

14. In the displayed Edit Relationships dialog box, click the Enforce Referential Integritycheck box, and then click Create. Compare your screen with Figure 4.

A one-to-one relationship is created.

Access CH02 More Skills12.qxd 5/22/08 10:30 AM Page 4

17. In the displayed subdatasheet for the first record, click in the displayed append row, andthen type second

18. Press F, and then compare your screen with Figure 6.

The message informs you that you are not able to create two logons. In a one-to-onerelationship, an employee can have only one logon.

Copyright © 2009 by Pearson Education, Inc. All rights reserved.From Skills for Success with Microsoft® Office 2007 by Kris Townsend

Microsoft Access | Chapter 2 - Building a Relational Database and Creating Forms More Skills: SKILL 12 | Page 5 of 6

Subdatasheet forYour Name

Figure 5

Duplicate valuesnot allowed

Figure 6

Access CH02 More Skills12.qxd 5/22/08 10:30 AM Page 5

19. With the Access message still displayed, click Start , and then click All Programs. Clickto open the Accessories folder, and then click Snipping Tool.

20. In the displayed Snipping Tool program window, click the New button arrow, and thenclick Full-screen Snip.

21. Click the Save Snip button . In the Save As dialog box, navigate to your Access Chapter2 folder. In the File name box, type a02_Employee_Logons_Snip_Your_Name and thenclick the Save Snip button. Close the Snipping Tool window.

If you do not have the Snipping Tool, which is available in Windows Vista HomePremium edition, press p, and then paste the screen into a Word document.

22. In the displayed Access message, click OK. Press E to cancel adding the second logon.Close the table, and then Exit Access.

23. Print a02_Employee_Logons_Snip_Your_Name or submit your files electronically asdirected by your instructor.

� You have completed More Skills 12

Copyright © 2009 by Pearson Education, Inc. All rights reserved.From Skills for Success with Microsoft® Office 2007 by Kris Townsend

Microsoft Access | Chapter 2 - Building a Relational Database and Creating Forms More Skills: SKILL 12 | Page 6 of 6

Access CH02 More Skills12.qxd 5/22/08 10:30 AM Page 6