A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Product table



 
 
Thread Tools Display Modes
  #1  
Old April 21st, 2010, 05:03 PM posted to microsoft.public.access.gettingstarted
Lynn
external usenet poster
 
Posts: 428
Default Product table

Ok sorry i am very new to access. i am trying to create a database for the
small company i work for. We have products that have manufacturer dates. So i
can have one particular product code with many manufacturer or batch dates in
stock. how do i create a table or relationship that shows one product with
many batch dates with quantities? hope this makes since.
  #2  
Old April 21st, 2010, 05:13 PM posted to microsoft.public.access.gettingstarted
Steve[_77_]
external usenet poster
 
Posts: 1,017
Default Product table

Something like .......
TblManufacturer
ManufacturerID
ManufacturerName

TblProduct
ProductID
ProductName
ProductCode
ManufacturerID

TblProductInventory
ProductInventoryID
ProductID
ManufacturerDate
QuantityInStock

Steve



"Lynn" wrote in message
...
Ok sorry i am very new to access. i am trying to create a database for the
small company i work for. We have products that have manufacturer dates.
So i
can have one particular product code with many manufacturer or batch dates
in
stock. how do i create a table or relationship that shows one product with
many batch dates with quantities? hope this makes since.



  #3  
Old April 21st, 2010, 06:37 PM posted to microsoft.public.access.gettingstarted
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default Product table

I assume the products are manufactured by your company rather than purchased
from external suppliers, with each batch of each product having a manufacture
date. If so, tables such as the following can be used:

Products
….ProductID (primary key)
….Product

Batches
….ProductID (foreign key)
….ManufactureDate
….Quantity

The primary key of the Batches table would be a composite one made up of the
ProductID and ManufactureDate columns.

If you also have tables recording sales of products, e.g.

Sales
….SaleID (primary key)
….CustomerID (foreign key)
….SaleDate

SaleDetails
….SaleID (foreign key)
….ProductID (foreign key)
….ManufactureDate (foreign key)
….Quantity

The primary key of this table is a composite one of SaleID, ProductID and
ManufactureDate if a sale can include the same product from more than one
batch, or SaleID and ProductID if from only one batch. Note that ProductID
and ManufactureDate constitute a composite foreign key referencing the
composite primary key of Batches.

Customers
….CustomerID (primary key)
….Customer

The current stock in hand per batch can now be computed with a query which
subtracts the sum of all sales per batch from the sum of the quantity
manufactured per batch:

SELECT Product, ManufactureDate,
SUM(Batches.Quantity) - SUM(SaleDetails.Quantity) AS StockInHand
FROM Products, Batches, SaleDetails
WHERE Batches.ProductID = Products.ProductID
AND SaleDetails.ProductID = Batches.ProductID
AND SaleDetails.ManufactureDate = Batches.ManufactureDate
GROUP BY Product, ManufactureDate;

If you are not discriminating between batches in sales then the stock in hand
per product can be computed by a similar query which subtracts the sum of all
sales per product from the sum of the quantity manufactured per product:

SELECT Product,
SUM(Batches.Quantity) - SUM(SaleDetails.Quantity) AS StockInHand
FROM Products, Batches, SaleDetails
WHERE Batches.ProductID = Products.ProductID
AND SaleDetails.ProductID = Batches.ProductID
GROUP BY Product;

Ken Sheridan
Stafford, England

Lynn wrote:
Ok sorry i am very new to access. i am trying to create a database for the
small company i work for. We have products that have manufacturer dates. So i
can have one particular product code with many manufacturer or batch dates in
stock. how do i create a table or relationship that shows one product with
many batch dates with quantities? hope this makes since.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...arted/201004/1

  #4  
Old April 21st, 2010, 06:46 PM posted to microsoft.public.access.gettingstarted
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default Product table

Come to think of it the first query, to compute the stock in hand per batch,
doesn't need to sum the quantity per batch as this is a single value per
batch, so:

SELECT Product, ManufactureDate,
Batches.Quantity - SUM(SaleDetails.Quantity) AS StockInHand
FROM Products, Batches, SaleDetails
WHERE Batches.ProductID = Products.ProductID
AND SaleDetails.ProductID = Batches.ProductID
AND SaleDetails.ManufactureDate = Batches.ManufactureDate
GROUP BY Product, ManufactureDate, Batches.Quantity;

Ken Sheridan
Stafford, England

--
Message posted via http://www.accessmonster.com

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:59 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.