Hi Emily
OK, so you need a table of ItemTypes, with a primary key (could be an
autonumber), the name of the item type (pencil, pen, eraser, etc), and a
description.
Then you need a table of items, with a primary key (PK) to uniquely identify
each one (this could be another autonumber, or it could be the unique serial
number). This table also requires an ItemType field corresponding to the PK
in the ItemTypes table. You create a one-to-many relationship between
ItemTypes and Items.
Then you need a Borrowers table. Once again this must have a unique PK, and
other information about the borrower: name, address, etc.
Next you need a Loans table. This contains the borrower's PK and the item's
PK, and also the date borrowed, the date due back, the date returned, and
any other data related to that particular loan (for example, fees for the
loan).
Now, items are unavailable for loan if there exists a record in the loans
table with a date borrowed, but no date returned. The converse is true to
find which items *are* available.
For example, if the ItemTypeID for a "Pencil" is 1, then you can get a list
of the available pencils with the following query:
Select ItemID from Items where ItemType=1
and not exists (Select ItemID from Loans
where Loans.ItemID=Items.ItemID and DateReturned is Null);
So, when a borrower requests 3 pencils, 2 pens and 1 eraser, you can select
from the "available" list for each item type and create a "loan" record with
that ItemID and the BorrowerID and the DateBorrowed.
As the items are returned, you select the item from a list of outstanding
loans for that borrower, and mark it as "returned" (which fills in the
DateReturned field).
Once you have created this structure, you have the ingredients for your
cake! Come back here if you need some help with the recipe ;-)
The pencils are not the same,. They will have pencils, eraser, pen and
etc.
[quoted text clipped - 41 lines]