I've simplified the details here, but here's what the item table might look like if no items had individual serial numbers:
Expand|Select|Wrap|Line Numbers
- Items
- -----
- Barcode [PK]
- Description
- CurrentStock
- MinimumStock
- AssignedStock
- -------------
- JobNo [PK]
- ItemBarcode [PK] [FK]
- QuantityAssigned
Expand|Select|Wrap|Line Numbers
- Items
- -----
- Barcode [PK]
- Description
- MinimumStock
- Serials
- -------
- SerialNo [PK]
- ItemBarcode [FK]
- AssignedStock
- -------------
- ItemSerialNo [PK] [FK]
- JobNo
My problem is that while some items are individually tracked with serial numbers others are not, just a note of quanities is used. I can't figure out a comprimise between the designs which allows for this.
Here is a design I'm thinking of:
Expand|Select|Wrap|Line Numbers
- Items
- -----
- Barcode [PK]
- Description
- CurrentStock {this might not match result of querying on Serials/AssignedStock}
- MinimumStock
- HasSerialNo
- Serials
- -------
- SerialNo [PK]
- ItemBarcode [FK] {where HasSerialNo = true}
- AssignedStock
- -------------
- JobNo [PK]
- ItemBarcode [PK] [FK]
- ItemSerialNo [FK] {null if HasSerialNo = false}
- QuantityAssigned {1 if HasSerialNo = true}