|
[ABC home] [ABC Archives by Issue] [ABC Archives by Author] [Search] [Privacy]
|
Joins: Now that we have a better understanding of relationships, let's look at
Joins. A join is the representation of a relationship in a query. It is the
tool used to tell your query in what way you want your related data
retrieved. There are three types of joins: Inner, Left Outer, and
Right
Outer. The first is the most common, the inner join. The Inner Join returns
only data that matches in both tables. The Left Outer Join returns all data
from the left table in the query window and only the matching data on the
right table. The Right Outer Join does just the opposite. It returns all
data from the right table and only matching data from that on the left.
This query will provide us with data where the CustomerID matches in both tables. Now let's take a hypothetical situation and adjust the query for it. The Marketing Director at Northwinds Trading Company has asked you to provide him a report of all customers and how many orders each placed in December of 1994.
Did you notice how Access automatically placed pound signs (#) around the
dates? The pound sign is how Access recognizes the Date format, and it's a
good way to know if you've entered a date properly.
Congratulations! You have created an Outer Join (specifically, a Left Outer Join). Referential Integrity: According to the Access 97 help index, "Referential integrity is a system of rules that Microsoft Access uses to ensure that relationships between records in related tables are valid, and that you don't accidentally delete or change related data." This means that Access will help you enforce rules so that your data (a) is valid to start with and (b) remains valid throughout its usage.
Cascade Update Related Fields is an extremely useful option to use if your data - past, present, and future - relies on the most up to date information. A Cascade Update replicates your changes to data throughout your database. If you changed information in your primary table, Access would make that change in all of the related tables. Since this is a somewhat difficult concept, I will try to give you a business example. A Billing department needs the current address of all its customers regardless of where they lived when the product was shipped. The Billing department using Cascade Update has an advantage in that they only need to update the Billing Address in one place, and that change is reflected on all records, both past and future. There are also times where it's not a good idea to Cascade Update; for instance, in an employee table. If Joe Cool receives a salary increase and his commission percentage increases, you do not want to use Cascade Update because his commissions on past sales should remain unaffected by the change. Cascade Delete Related Records can be dangerous and should be used with extreme caution. They do something similar to the Cascade Update. When you delete a record in a primary table, that deletion is carried out on all related or child tables as well. In some cases (a purge of outdated material, for instance) and this can be very helpful. It is also dangerous, as it can have disastrous outcomes. If you choose to use Cascade Delete for purging old records, it is recommended that you turn it on only long enough to complete your purge, then turn it off. Remember that in Access, once your data is gone, it is gone! The Undo option usually will provide you no solace and unlike Word and Excel, you cannot simply choose to not save your changes. If you have any questions regarding this lesson, why not join our Access Intermediate class at Eclectic Academy? We will be going into more detail on the multiple table queries.
|
|
Privacy Policy, Disclaimer, and Legal Stuff This page was last updated on Tuesday, September 23, 2008 . copyright © 2000 - 2008, Linda F. Johnson, Linda's Computer Stop, ABC ~ All 'Bout Computers. All rights reserved. |