Download presentation
Presentation is loading. Please wait.
Published byLora Martin Modified over 6 years ago
1
Learning Objective: What is referential integrity and how does it enhance marketer productivity when using a database? Discuss the implications of the distinction between inner and outer and between right and left joins for businesses like Green Mountain Animal Hospital. What implications do these distinctions have for the contents of queries the marketer creates using joined tables. Discuss the question of transitivity. Why and how is the result of a query affected by the number of tables in the field list when the query is run? Be prepared to distinguish ambiguous from unambiguous outer joins.
3
$ Productivity Drivers Creation of Value Through Exchange
Competition: $ $ (Falling Prices) $ Productivity Drivers $ $ $ $ $ $ $ $ $ $ $ $ Mass Marketing Customize, target low incidence, high value customers Mass Customization DATABASE Marketer Pushes Product (Queries, Mail Merge) Customer Pulls Product (Web App) 1 to to 1 Segmentation & Targeting Identifying Segments Measuring Market Segment Value: Predicting Consumer Response (Models) Cluster Analysis Gain Scores Lifetime Value Analysis Non-Statistical Table Design Relationship Editor --Joins: 1 to 1, 1 to ∞. ∞ to ∞ Queries --Select Query (Bring data from one or more tables into virtual table.) ● Sort ● And / Or Logic --Inner / Outer Join RFM (current customers) Market Basket Analysis (Web, Directed Web, Apriori) +Error: False Positive -Error: False Negative Will Buy Won’t Buy
4
Relationship Properties Menu Join Properties Menu
5
∞ No Pet in Pet Table
6
Sources of Customers with no Database Pet
7
∞ No Owner in Pet Table
8
Pets with no Owners Privacy Fanatic Gorillas Wild Animals
Grocery Shoppers
9
Objective: Create a composite table showing
known pet/owner dyads. (Not Municipal Zoo, Oregon Nature Center, Bobo, or Presto)
12
Campaign Want to send mail merge letter to all customers in
database. If they have a pet, the pet name will be included in the letter. If not, “your pet” will be inserted into pet name slot.
13
Objective: Create a composite table showing
all customers/prospects and all pets which have an identifiable owner. (Not Bobo and Presto.)
16
Left and right outer join is not related to
whether a table is found on the left or right. Both joins above are left outer joins.
17
Campaign Want to contact all customers in database who have a pet
but have never come to Green Mountain Animal Hospital. Offer discount coupon for first visit.
18
Campaign Want to contact all customers in database who have a pet
but have never come to Green Mountain Animal Hospital. Offer discount coupon for first visit.
19
Campaign We want to do a market basket analysis. Need all purchases
made at store. Where customers known, we want their information included so we can profile them. But we want to include purchases made with cash where customer not known.
20
Objective: Create a composite table showing
all pets and all owners who have a known pet. (Not Municipal Zoo or Oregon Nature Center)
23
Matrix of Records Selected
Primary Related Table Table ∞ Records with matched field in Related table Records with matched field in Primary table (1) (2) (3) Records with matched field in Primary table All Records Records with matched field in Related table All Records
24
Outer Join Outer Join Join
25
Joins in Relationship Editor
26
Joins with Referential Integrity Joins without Referential Integrity
27
Signs in Relationship Editor
1: Primary table (one) side Bold: On primary table (one) side ∞: Related table (many) side : Arrow touches side from which only matched records selected. ∞ Left outer join Right outer join
28
Relationship Editor Interpretation Rules:
-- Enter 1 on primary key side and ∞ on the foreign key side when labeling join lines that don’t have written in symbols. -- Dual or “concatenated” keys are always on the ∞ side. -- Every join line is either a 1 to 1 or a 1 to ∞ join. -- Bridge tables with multiple ∞ symbols set up many to many relationships between tables connected to the bridge table. One bridge table can set up more than one many to many. -- If a table has three or more ∞ symbols, be sure to match every ∞ with every other ∞ including matching ∞ symbols that are on the same side of the table. Each ∞ ∞ pair creates a many to many relationship. -- If a join has rectangles on each end, it is an inner join. -- Arrows indicate outer joins. If the arrow touches the primary key, it is a Right Outer Join. If the foreign key, it is a Left Outer Join.
29
*
31
Relationship Editor Assignment
32
Changing Join Type There are two ways to change the
join type. Both involve right clicking the join line, then selecting the Join Properties menu. You can do this in the Relationship Editor or in a query. The tip of the cursor must be right on the line when you click it to open the menu.
33
Changing Join Type Right click exactly on the line (as shown right),
then select Join Properties, then choose the appropriate join type option, 1 for inner join, 2 for left outer join, or 3 for right outer join.
34
Use Joins in Ever After Database Not Ever After Database For this exercise
35
Sample Exercise How many products are there in the Everafter wedding
database that no one has ever purchased?
37
Sample Exercise What is the average finder’s fee
of vendors who do not have any product listed in the Products table (i.e., have not yet supplied a product) versus vendors who do have a listed/supplied product?
38
Vendors with no listed product Vendors with listed product
39
Sample Exercise How many brides do not have an associated groom and how many grooms are there without an associated bride?
40
Brides with no grooms Grooms with no brides
41
Workshop Exercises How many zip codes are there in the brides table that are not matched by zip codes in the zip table.
42
Answer:
43
Workshop Exercises Are there any bridesmaids who are not associated with a bride?
44
Answer:
45
Workshop Exercises Are there any brides who don’t yet have a bridesmaid?
46
Answer:
47
Workshop Exercises How many brides are there for whom there is no marketing research information? How many brides are there for whom there is marketing research information?
48
Brides for whom there is no marketing research Brides for whom there is marketing research Answer: Answer:
49
Workshop Exercises How many brides are there who have no guests entered in the Guest table.
50
Answer:
51
Workshop Exercises Create a query that contains the PID, PName,
and PClass for all products in the database whether or not anyone has yet bought that product. For those that have been purchased, multiply the price times the quantity, then sum up all sales for each product. Do an ascending sort on that invoice value. If you have done query right, some invoice values will be blank. How many blank values are there?
52
Workshop Question Answer:
53
Workshop Exercises Some musical groups have not been booked.
You wonder if it is because they charge too much. What is the average cost of groups that have not been booked and of those that have been.
54
Workshop Question Answer not booked: Answer booked:
55
Blue Gazelle Assignment
56
Join Transitivity Effects
57
Query With Single Table
10 Records
58
Same Query With Two Tables
12 Records
59
Join Transitivity Effects
Query results are affected by the number of tables linked in the field list. This happens because the joins between tables affect record selection, even when no fields from a given table are included in the query.
60
Ambiguous Outer Joins
61
Ambiguous Outer Join An ambiguous outer join occurs
when ACCESS can’t tell which of two joins should be done first and when the output will differ depending on which is done first.
62
Ambiguous Outer Join
63
Customer Pets then CustomerPets Visit Pets Visits then Customer PetsVisits
64
Unambiguous Outer Join
65
Only One Possible Outcome
66
Identifying Ambigious Joins
If all are inner joins, no problem. Arrows point away from middle table (away from other joins), no problem. 3.If an arrow points to inner table, other join must point in same direction, i.e., away from the inner table. Ambiguity arises when arrows point towards each other or arrow points to an inner join.
71
Referential Integrity
72
In which fields is it most important to avoid errors? Why?
74
Useful Dangerous
75
When we try to link two tables we must decide whether to establish referential integrity between tables.
76
Basic Referential Integrity Rule:
For every record in a child table (the table on the “many” side of a 1 to relationship), there must be one and only one matching record in the parent table (the “one” side of a 1 to relationship).
77
Basic Referential Integrity Rule:
Each foreign key value in a child table must have a corresponding primary key value in the parent or primary table. Thus, the primary table sets the domain or range of acceptable values for the related table. If a value isn’t in the parent/primary table, it can’t appear in the child/related table.
78
Specific Referential Integrity Rules:
You cannot delete a parent record if there is still a related child record You cannot change the primary key value in a parent table as long as there are related records in the child table You cannot enter a child record for which there is no parent record You cannot change a child record so that its foreign key does not have a match in the parent table
79
Primary Table Related Table Employee Salary
Orphan Record: No ID in primary table
80
Joining Fields Versus Other Fields
Fields that join tables (especially those that have referential integrity) have a very different function from other data fields. ACCESS should and does treat them differently, restricting changes that can be made in them if they threaten the linkages between tables.
81
Summary of Main Database Features
82
Tables Required for Query
-- To run query, must have tables from which fields are taken plus any bridge tables that connect tables from which data are taken. -- Never run a query if tables are not joined by primary and foreign keys (as in example)
83
Query By Example Grid -- Post Tables -- Select Fields from Tables
-- Sort fields alphabetically or numerically -- Set criteria for selecting records using AND or OR logic
84
Total Query -- Opened with sigma: ∑ -- Used to carry out a function on
a single field. -- Most important functions aggregate values, i.e., add or average or count them. -- GROUP BY groups aggregate values by values in the group by field -- WHERE selects values that specified in criteria but does not group them. Treats them as one big group.
85
Expression Builder -- Opened with wizard wand -- Normally used for
operations involving more than one field, e.g., to multiply or divide one field by another. -- Point and click to select tables and fields in tables -- Use parentheses ( ) to control order of operations.
86
Relationship Editor -- Best place to get the overview of the database with all tables, fields, joins, and referential integrity.
87
Inner and Outer Joins Joins determine which records
will be selected when query is run. Inner joins select only records found in both tables. Outer joins select all records from one table, only matched records from the other.
88
Language Marking Joins
Create a query that includes all records from the customer table but only matched records from the transaction table. Create a query that includes only those customers who have made a purchase.
89
Note that all key database
features are reviewed in the Review of Major Database Features Powerpoint posted after this one.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.