Guys I have a general question.
In a stock control system:
I have two models, Item and Supplier. Item HABTM Supplier and Supplier
HABTM Item. This uses the following tables:
items:
id | description | attribute1 | attribute2 |
etc.... | etc..
suppliers:
id | name | address | contact |
phone_number | etc..
items_suppliers:
item_id | supplier_id
Now, I want to be able to keep track of which suppliers can provide
which items and the delivery times and prices offered by each supplier.
Therefore, I keep this information in the items_suppliers link table,
along with item_id and supplier_id.
This way, when an item is selected, I can list the item with the
details specific for each supplier.
e.g.:
item_id | supplier_id | supplier_price |
delivery_time | num_in_stock
However, there may be a situation where I already have some of a
particular item, from a particular supplier in stock, but I get more in
from the same supplier at a different price.
I'm thinking I should do one of the following:
(a)
Extend the PK of the link table to include the supplier_price as well
as item_id and supplier_id. However this will mean duplicating the
delivery_time data. I'm also wondering if extending the PK like this
will affect Cake's understanding of the Model.
OR
(b)
Create a third Model called Stock which has the following:
item_id | supplier_id | supplier_price | num_in_stock
leaving the items_suppliers link table as:
item_id | supplier_id | delivery_time
This avoids the duplicating the delivery_time but adds the extra table,
and therefore duplicates item_id and supplier_id.
OR
(c)
I could just put supplier_price and num_in_stock back into the 'items'
table and extend the PK to include supplier_id and supplier_price
giving me the following:
items:
id | description | attribute1 | attribute2 |
supplier_price | num_in_stock | etc.... | etc..
However, again, I'm wondering if extending the PK like this will affect
Cake's understanding of the Models.
Any thoughts would be greatly appreciated.
Cheers,
Sonic
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---