|
CSCI A114 / INFO I111
|
We start from the entities of yesterday:
Do they interact in any way?
I suppose PATRONS actually BORROW from the set of BOOKS.
So now we have a link.
Three tables.
PATRONS also RETURN those BOOKS that they have borrowed, when they're due.
So now we have four tables.
But BORROW and RETURN need also be linked.
So we'd have 5 tables.
We will simplify this design by introducing a TRANSACTIONS table.
Assume we have 7 (seven) books in the library.
We said we will introduce a TRANSACTIONS table.
Here is a list of all the transactions.
We create a TRANSACTION table with this data.
We then look at the queries.
Here's one of the queries.
Here's another one.SELECT STUDENTS.Name, * FROM BOOKS, TRANSACTION, STUDENTS WHERE BOOKS.ISBN = TRANSACTION.ISBN AND STUDENTS.Username = TRANSACTION.Username AND DateIn IS NULL AND (DateOut + 14 < #10/10/2001#) ORDER BY STUDENTS.Name DESC;
Remember everything starts from the cartesian product of the sources.
Here's another query.
Another query.SELECT ISBN, Avg(Rating) AS Rank FROM TRANSACTION GROUP BY TRANSACTION.ISBN ORDER BY Avg(Rating) DESC;
Let's then discuss query 4:SELECT Name, COUNT(*) FROM STUDENTS, TRANSACTION WHERE Username = Student;
List all good books (average ranking greater than 3.3) that are overdue.You need to rely on query 1, and 2 for that, and select from their JOIN
Last query simply checks for the occurrence of a particular string in the list of topics.
Then we ask this question: what books are not checked out?
A114/I111