Download presentation
Presentation is loading. Please wait.
Published byBrent Robert Hopkins Modified over 8 years ago
1
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-1 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary CREATING RELATIONSHIPS BETWEEN DATABASE TABLES Chapter 2 Microsoft Access 2007 – Level 1
2
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-2 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Performance Objectives Create a database table with a primary key Create a database table with a foreign key Create a relationship between database tables Print table relationships Display Subdatasheets
3
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-3 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Creating Related Tables Access is a relational database management system Relationships are defined between sets of data (tables) –allows greater flexibility in manipulating data –eliminates redundancy
4
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-4 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Determining Relationships Planning is most important Break down fields into tables to avoid redundancies Clients table Client # Client Street Address City State Zip Code Insurance table License # Client # Insurance Code Uninsured Motorist Coverage table Insurance Code Type of Insurance Claims table Claim # Client # License # Date of Claim Amount of Claim Notice that each table is about only one subject Some fields appear in more than one table – they are used to create a relationship
5
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-5 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Creating a Primary Field Need to designate a primary (key) field in a table before creating a relationship between tables Must contain unique data Access enforces Entity Integrity –expects a value in the primary field in each record –cannot close a table containing a null value in a primary (key) field
6
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-6 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Creating a Primary Field…/2 Open table in Design view Position insertion point in field Click Primary Key button Notice image of key To define more than one field as the primary key, select the rows and click the Primary Key button
7
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-7 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Creating a Foreign Key A primary key field in one table may be a foreign key in another Primary key and foreign key form a relationship between the tables Clients table Client # Client Street Address City State Zip Code Insurance table License # Client # Insurance Code Uninsured Motorist Coverage table Insurance Code Type of Insurance Claims table Claim # Client # License # Date of Claim Amount of Claim
8
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-8 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Establishing a Relationship Relate one table to another by joining the tables –data can be extracted from both tables Define the type of relationship to be created –one record in the primary table will match zero, one, or many records in the related table (one-to-one, or one-to-many) Set Referential Integrity –a record must be added to the “one” table before it can be added to the “many” table
9
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-9 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Creating a One-to-Many Relationship Open database file Click Database Tools tab, Relationships Show Table dialog box appears when no relationships have been defined yet
10
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-10 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Creating a One-to-Many Relationship…/2 Double-click each table to add it to the Relationships window After adding all the tables Repeat until all required tables are added Click Close when done adding Notice that the Primary keys are indicated
11
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-11 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Creating a One-to-Many Relationship…/3 Drag the common field from the primary table (the “one”) to the related table (the “many”) Edit Relationships dialog box appears Ensure that the correct tables and field names display Make sure type is One-To-Many Click Check options as desired
12
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-12 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Creating a One-to-Many Relationship…/4 Join line is thick at both ends if referential integrity option has been chosen Save the Relationship by clicking the Save button in the Quick Access toolbar Join line This join line shows that each client may have many claims (1 to ∞)
13
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-13 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Specifying Referential Integrity If a related table contains a record, you will not be able to change or delete a primary key value in the primary table As you change a primary key value in the primary table, Access will automatically update the matching value in the related tables As you delete a record in the primary table, Access will also delete any related records in the related tables
14
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-14 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Printing Database Relationships With the Relationships open, click the Relationship Report button The Relationships report in Print Preview Click the Print button in Quick Access toolbar
15
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-15 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Creating Additional Relationships Open Relationships if necessary and click the Show Table button to add other tables to the database relationships Drag a primary key in one table to a foreign key in another table Follow the same procedure as before to verify the table fields and the relationship type, and to set the desired referential integrity
16
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-16 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Editing a Relationship Right-click a join line and click Edit Relationship OR Can move a table entry by dragging its Title bar Open Relationships … Click a join line and click OR Double-click a join line
17
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-17 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Deleting a Relationship Open Relationships … Right-click a join line and click Delete OR Click a join line and press the Delete key
18
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-18 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Showing a Subdatasheet Click + sign preceding desired record + expands - collapses Select table Click OK
19
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-19 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Displaying Related Records in a Subdatasheet Can view, edit or add data in the subdatasheet Click + sign preceding desired record + expands - collapses Only available when tables have relationships
20
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-20 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Managing Subdatasheets Can choose a different subdatasheet With an open table … Click Home tab, More button (in the Records group) Can remove the subdatasheet Same as clicking the + or – preceding each record of the table
21
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-21 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary How do you identify a primary key? Features Summary Image of a key shows by the field name
22
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-22 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary How do you display the Relationships window? Database Tools tab, Relationships button Features Summary
23
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-23 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary How do you display the Edit Relationships dialog box? Features Summary Right-click a join line and click Edit Relationship OR Click a join line and click OR Double-click a join line
24
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-24 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary How do you display the Show Table dialog box? Database Tools tab, Relationships, click the Show Table button Features Summary
25
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-25 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary How do you print database relationships? With the Relationships open, click the Relationship Report button Click the Print button in Quick Access toolbar Features Summary
26
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-26 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary How do you display the Insert Subdatasheet dialog box? Features Summary Click the + sign preceding a record Click Home tab, Records group, More button, Click Open a table OR Features Summary
27
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-27 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining Relationships Determining Relationships Primary Keys Foreign Keys Relationships Referential Integrity Referential Integrity Printing Relationships Printing Relationships Subdatasheets Features Summary Features Summary Coming Next MODIFYING AND MANAGING TABLES Chapter 3
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.