I have four tables with unique records as shown below. I'd like to add a record for a new item to the database by selecting the values from combo boxes for Supplier, Item and Unit. If the values do not exist the user would then type in a new value. SuppliersItemCode and Cost would always be new values. What's the best way to go about this? I am unsure how to add a record to a normalized database where you sometimes have to use / reference existing unique values in multiple tables via foreign keys for the new record.
The logic of the form would be:
1. Select existing or add new Supplier.
2. Select existing or add new Item.
3. Select existing or add new Unit.
4. Enter new SuppliersItemCode
5. Enter Cost
Suppliers
---------
SupplierID (primary key)
Supplier (indexed unique)
Items
------
ItemID (primary)
Item (indexed unique)
Units
-----
UnitID (primary key)
Unit (indexed unique
SuppliersCostsAndCodes
-----------------------
SuppliersItemCostCode (primary key)
Cost
ItemID (foreign key)
UnitID (foreign key)
SupplierID (foreign key)
Any advice or assistance is greatly appreciated, thank you.
The logic of the form would be:
1. Select existing or add new Supplier.
2. Select existing or add new Item.
3. Select existing or add new Unit.
4. Enter new SuppliersItemCode
5. Enter Cost
Suppliers
---------
SupplierID (primary key)
Supplier (indexed unique)
Items
------
ItemID (primary)
Item (indexed unique)
Units
-----
UnitID (primary key)
Unit (indexed unique
SuppliersCostsAndCodes
-----------------------
SuppliersItemCostCode (primary key)
Cost
ItemID (foreign key)
UnitID (foreign key)
SupplierID (foreign key)
Any advice or assistance is greatly appreciated, thank you.