CIS 200 AU 97

advertisement
Exercise 11.4 Antique Cars Database
Page 1
Access Problem:
As the president of your antique car club, you have set up a database to keep track of your members’
information for your annual club picnic. Portions of each data table are listed below.





The Members table is a list of the names and addresses of your club members. (Each member is identified
by his or her member ID.)
The Spouses table keeps track of the names of the spouses of your club members. You can assume that
each member will only have one spouse at any given time. Unmarried members will not have a row on
this table.
The Children table lists the names, birthdates, and genders of the members’ children.
The Cars table lists information about the members’ cars. Some members may hav e multiple antique cars
that they register with the club, while other members may have none.
The ClubPayments table keeps track of all the payments that members make to the club. The memberID
of the member making the payment is listed with the date of the payment and the amount that was paid.
1. Write a query named AutoList in the design view below to summarize car info by member ID. For each
member that has at least one car registered with the club, list the member ID, the member’s full name, the
number of antique cars they have, and the model year of the oldest car they own.
2. Write a query named AutoList in the design view below to summarize car info by member ID. List the
member ID, the member’s full name, the number of antique cars they have, and the model year of the
oldest car they own.
3. What different records will be generated by each of the two previous queries, AutoList and MemberList?
Explain the values you expect to find in the total number of cars and average age fields.
Because MemberList requires an outer join, it lists info for all members regardless of whether or not they
have any antique cars. AutoList uses an inner join, so it only lists the member info for those members that
have antique cars, i.e. those members that appear on both the Members and Cars tables. Two different
record sets will be generated. The MemberList will include records for members 4 and 6 that have no
antique cars, these will not be included on the AutoList query. The minimum year would result in a null
field for these members with no cars and the number of cars will result in a 0.
4. Write a query named ColumbusCars to calculate the number of antique cars that are registered to
Columbus residents. (Hint: This query will return only 1 value, not a list of data.)
5. Your auto club would like to arrange a singles night for its unmarried members. Write a query named
Unmarried to list the full names and phone numbers of all members who do not have a spouse. (Hint: use
an Outer Join with a criterion of “Is Null” for the Spouse Name field.)
6. At the annual club picnic, special activities are provided for the members’ children. Because of this, each
member is charged $10 for each child attending the picnic. (You can assume that all the members’
children will be attending.) Write a query or queries to list for all members the amount that each member
owes for his or her children, the total amount of payments that he or she has already made, and the
amount that he or she still owes to the club.
Page 2
Query Name: AutoList
Tables Required: Members/Cars
Join On: (Also Known as the Foreign Key) MemberID
Join Type: Inner
Field
MemberID
FName
LName
MemberID
Year
Table
Members
Members
Members
Cars
Cars
Total
Group By
Group By
Group By
Count
Min
x
x
x
x
x
Sort
Show
Criteria
OR
OR
Additional Room for Expressions if needed:
Query Name: AutoList
Tables Required: Members/Cars
Join On: (Also Known as the Foreign Key) MemberID
Join Type: Outer
Field
MemberID
FName
LName
MemberID
Year
Table
Members
Members
Members
Cars
Cars
Total
Group By
Group By
Group By
Count
Min
x
x
x
x
x
Sort
Show
Criteria
OR
OR
Additional Room for Expressions if needed:
Page 3
Query Name: Columbus Cars
Tables Required: Members/Cars
Join On: MemberID
Join Type: Inner
Field
MemberID
City
Table
Cars
Members
Total
Count
Where
Sort
Show
x
Criteria
“Columbus”
OR
OR
Additional Room for Expressions if needed:
Query Name: UnMarried
Tables Required: Members/Spouses
Join On: MemberID
Join Type: Inner
Field
MemberID
LName
Phone
Spouse Name
Table
Members
Members
Phone
Members
Total
Sort
Show
X
X
Criteria
X
Is Null
OR
OR
Additional Room for Expressions if needed:
Page 4
Query Name: Query 6A
Tables Required: Members/Children
Join On: MemberID
Join Type: Outer
Field
MemberID
MemberID
Table
Members
Children
Total
Group By
Count
Charges:[CountOfMemberID]*10
Expression
Sort
Show
X
X
X
Criteria
OR
OR
Additional Room for Expressions if needed:
Query Name: Query 6B
Tables Required: Members/Payments
Join On: MemberID
Join Type: Outer
Field
MemberID
AmtPaid
Table
Members
Payments
Total
Group By
Sum
Sort
x
x
Show
Criteria
OR
OR
Additional Room for Expressions if needed:
Page 5
Query Name: Query 6C
Tables Required: Query 6A/Query 6B
Join On: MemberID
Join Type: Inner
Field
Balance: NZ([Charges],0) –
MemberID
Charges
SumOfAmount
Query 6A
Query 6A
Query 6B
Table
NZ([SumOfAmtPaid],0)
Total
Sort
Show
x
x
x
x
Criteria
OR
OR
Additional Room for Expressions if needed:
Page 6
Download