R
Ramzi
Hi,
Its easyer to join table 2 and 3 together and use fields QtyIn and QtyOut.
Its easyer to join table 2 and 3 together and use fields QtyIn and QtyOut.
Ken Sheridan said:You have a lot of redundancy in your tables at present in that product names,
descriptions and serial numbers are repeated in more than one table. Also
your 'Currently In' table is holding values which can be computed from the
other two, i.e. the number in stock of a product is the sum of all deliveries
of that product less the sum of all removals from stock of the product. This
leaves the database open to inconsistent data creeping in.
In a relational database tables model entity types, with their columns
representing attribute types which are specific to the products entity type
(in the jargon they are said to be functionally dependent solely on the whole
of the table's primary key). A more appropriate model would be made up of
the following tables:
1. Products: this would have one row per product and columns such as
ProductID (the primary key), Productname, ProductDescription, SerialNumber,
ReorderLevel.
2. Deliveries: this would have columns ProductID (a foreign key
referencing the primary key of products), DeliveryDate, DeliveryNoteRef,
Quantity. Your current stock in hand would be inserted as rows into this
table.
3. Removals: this would have columns ProductID (a foreign key referencing
the primary key of products), RemovalDate, JobNumber, Quantity
You also show a Supplier column in your 'Out' table, but I'd have thought
that should pertain to Deliveries, so you'd have a SupplierID foreign key
column in that table.
In addition to these tables you'd also have a Suppliers table with
SupplierID as its primary key, and a Jobs table with JobNumber as its primary
key.
You can compute the quantity of products in stock in a query which subtracts
the sum of the quantity removed from stock from the sum of the quantity
delivered. The query can also include a computed column which indicates if a
product has reached or fallen below its reorder level.
You might also need to cater for stock being written off. This could be
done in a number of ways. The simplest would be to treat a write off as just
another removal from stock, e.g. to job number zero. A better solution would
be to have a separate WritteOffs table as you can then have a column's
specific to write offs, such as the reason, which would not be appropriate in
the Removals table.
If you'd care to mail me your file at:
kenwsheridan<at>yahoo<dot>co<dot>uk
I'd gladly take a look at it. Recasting your tables into the above model is
a fairly simple task using a few 'action' queries, and wouldn't take long.
Ken Sheridan
Stafford, England