COMP 1001 Winter 2005
Assignment #5
Due: March 31, 2005 (4:00 p.m.)
Part 1
Create a directory on your disk called Paradox and set it up as your Working Directory.
You are going to create a library database to keep track of students borrowers that do not return books on time, the books they borrow, and the time period that these books are overdue.
a) Create a Patrons table with the following fields:
Patron Number (e.g.. 0000000000A)
Student Number a 6 digit student number
Last Name
First Name
Date of Birth
Status (U for undergraduate or G for graduate)
Department a 2 digit department code (e.g.. 95 for Computer Science, 29 for Linguistics, 49 for Psychology)
Assign appropriate types, and, if necessary, sizes and keys. Save this table as "Patrons.db".
b) Create a Books table with the following fields:
Call Number (e.g.. RN.12345)
Title
Author
Date of publication
Type (e.g.. 95 for Computer Science books, 29 for Linguistics Books, 49 for Psychology books)
Assign appropriate types, sizes, and keys. Save as "Books.db".
c) Create a Records table with the following fields:
Patron Number
Call Number
Overdue Period 0-50 (The number of days the book is overdue)
Note that there is an Overdue Period for EVERY book that a patron borrowed. (Remember, this is the library's black book).
Assign appropriate types, sizes and keys.
Save this table as "Records.db".
d) Enter data for the above three tables following the conditions given below.
For the Patrons table there must be...
at least 10 students
at least 4 graduate students
there should be 4 people from computer science department (code 95), 2 from Linguistics (code 29) and 4 in Psychology (code 49).
For the books table there must be...
at least 30 different books
In the Records table...
the patron numbers and call numbers should be valid Patron Numbers from the Patrons table and the Call Numbers should be valid numbers from the Books table
each patron should have at least 3 book entries in the Records table for 3 different books. That is, each student must have at least 3 overdue books in order to be on this black list. Make up the number of days in the overdue period, ensuring that they are between 0 and 50.
Using a validity check, ensure that status (in Patrons table) is either U or G, and that only a two-digit number is in the department field.
--------------------------------------------------------------------------------
Part 2
In this part of the assignment, you will perform 12 different queries on the tables above.
Define a query on the Patrons table that will display the Patron Number, Student Number, Last Name, First Name and Department of all students in Linguistics. Save this query as "Linguistics.qbe".
Define a query on the Patron table to display all the fields for students who are in linguistics or computer science. Save this query as "LingComp.qbe".
Define a joined query on the Patrons, Books and Records tables that displays the Patron Number, Student Number, Last Name, First Name, book Call Numbers, book Titles and book Overdue Periods for all students. Note that each student should appear once for each book taken (hence, a student may appear many times in the query). Save this query as "Borrowers.qbe".
Define a query that retrieves all the linguistics or computers science books borrowed by all students in psychology or linguistics and displays the Patron Number, Student Number, both names, book Call Number, book Name and the Overdue Period for the book. The answer table should be sorted by the student's Family Name and by the book Call Number. Save this query as "Sort.qbe".
Define a query on the Records table that retrieves the Patron Numbers, Student Numbers, and Names of students, and calculates the overdue period average, the number of books borrowed and the minimum and maximum number of days for each borrower. Instead of displaying the first and last names in two separate fields, combine them into a single field. The name should be the first name followed by last name with a space in between. Save this as "Days.qbe". (Hint: use CALC with the AVERAGE, COUNT, MIN and MAX summary operators. There is also a SUM operator)
Define a query on the Patrons table to display all the fields for students whose family name starts with M. Save this as "Ms.qbe"
Define a query on the Patrons table that will display the Patron Number, Student Number and Last name of all graduate students in computer science. Save this as "Grad.qbe"
Define a query on the Patrons table to display all the fields for students whose given name sound like Tom (Hint: use LIKE). Save this as "Tom.qbe"
Define a query on the Patrons table to display the Patron Number, Student Number, Last name, Status, and Department of students who are undergraduate or who are in psychology. Save this as "UnderG.qbe"
Define a query on the Patron table that displays all the information for students who are born between January 1, 1962 and December 31, 1977. Save this as "BDays.qbe"
Define a query that retrieves all the books for a single Patron Number (make sure the Patron Number you choose exists in the table) and displays the Student Number, Call Number, and Title for each book borrowed by that student. Save this query as "Names.qbe". (Hint: you will need to join two tables)
Define a query to display all the student information sorted by the student's Last name in descending order. Save this as "SortLast.qbe".