Cse1111-Hw6C 1

advertisement
Name _____________________________
Lecture Time ________________
CSE1111 – Homework #6 (10 points) – Simple Queries
Patient
PatientID
LName
FName
Address
City
State
Zipcode
A2532
A6342
A3645
A4444
Smith
Cantor
Cavalieri
Korthik
Jeff
Heather
Albert
Mina
18 Simon Street
54 Elm Street
23 Maple Lane
17 Satts Place
Bexley
Dublin
Detroit
Bexley
OH
OH
MI
OH
43209
43218
48201
43209
Appointment
AppId
PatientID
1
A2352
2
A6342
3
A2352
4
A4444
DrId
M21
D12
M21
M21
Date
6/12/2003
7/13/2003
6/25/2003
7/21/2003
Doctor
DrId
LName
FName
StateCert
M21
D12
M54
M66
Barge
Torricelli
Mohr
Nando
James
George
John
Igor
Yes
No
Yes
Yes
Length
40
30
60
10
The tables provided above represent the database system for Barge and Mohr Health Associates.
The Doctor table lists the names of the doctors that are at the BMHA and if they are state
certified. The Patient table lists information for each of patient currently enrolled at BMHA.
The Appointment table lists each appointment and the appointment duration in minutes (length).
Assume the information above is only a partial listing of each table’s records.
1. (1 points) Database Relationships: set up the relationships of this database. Using the boxes
below, fill in the primary key (if any) of each table and draw relationship lines between
tables. Label each relationship with the name of the foreign key(s) just above the line you
have drawn.
Table name:
Doctor
Table name:
Appointment
Primary Key
Primary Key
Table name:
Patient
Primary Key
2. (1/2 point) Is LName field on the Doctor’s table a valid foreign key to the LName field on
the Patient table? Explain all of the reasons for your answer.
Cse1111-Hw6C.doc
1
3. (1 points) What field type (Text, Number, Currency, Date/Time, Yes/No, AutoNumber) is
best suited for each of the following fields:
PatientID (Patient Table):
Date (Appointment Table):
Length (Appointment Table):
StateCert (Doctor Table):
Zip (Patient Table):
Please note when writing query grids, to receive full credit you must use correct Access syntax. The
query should look identical to how it looks when the computer runs it. Be sure to include Like, “”, and
# symbols as needed. Do not use unnecessary tables, fields or criteria in your query.
4. (1 points) Using the query design view below, construct a query to list the doctors that are
not state certified. Your list should include the doctor’s last and first name.
Tables Used: ____________________________________
Field
Table
Total
Sort
Show
Criteria
OR
OR
5. (1/2 point) What dataset will result from this query – base this question on only the data
shown.
Cse1111-Hw6C.doc
2
6. (1 points) Using the query design view below, construct a query to list all patients that live in
either Bexley or Dublin. The list should be organized alphabetically by city and include the
patient’s full name and city of residence.
Tables Used: ____________________________________
Field
Table
Total
Sort
Show
Criteria
OR
OR
7. (1 points) Using the query design view below, write a query to list the PatientID, the DrID,
and the date of all appointments. Sort the result by date (most recent first), then by DrID
(alphabetically).
Tables Used: ____________________________________
Field
Table
Total
Sort
Show
Criteria
OR
Cse1111-Hw6C.doc
3
8. (1 points) List the last name and the first name of all doctors whose last name begins with the
letter B.
Tables Used: ____________________________________
Field
Table
Total
Show
Sort
Criteria
OR
9. (1 points) List all appointments after June 23, 2003 with Dr. Mohr (DrID M54) or after June
20, 2003 with Dr. Barge (DrID M21). Your list should include the AppID, the DrID and the
appointment date.
Tables Used: ____________________________________
Field
Table
Total
Sort
Show
Criteria
Cse1111-Hw6C.doc
4
10. (1 points) Write a query that summarizes the appointments by patient. The query should list
the patientID, the number of appointments and the average appointment length.
Tables Used: ____________________________________
Field
Table
Total
Sort
Show
Criteria
OR
11. (1 points) Each doctor charges a different rate for each patient. To make matters worse, the
price can also vary based on the type of visit the patient is having. To help out the
receptionists, the doctors of BMHA got together and decided that overall the average price
per minute is $1.45 plus a $20.00 setup fee. Write a query that lists the AppID, the
PatientID, the appointment date and the estimated appointment cost (name it estimate) for
each scheduled appointment.
Tables Used: ____________________________________
Field
Table
Total
Sort
Show
Criteria
OR
OR
Cse1111-Hw6C.doc
5
Download