On Fri, 2006-03-24 at 03:07 +0100, Petro Verkhogliad
wrote:> Hello all,
>
> I am working on building a web store with RoR. The company has many
> locations. All the stock/order information is processed through the same
> site.
>
> Here is my question. How would you handle the multiple warehouse problem
> with Rails? How would you keep track of the information in multiple
> warehouses?
This is a data modeling problem more than a Rails problem (at least
until you start implementing code to support the data model).
Assumed:
all primary keys are surrogate keys (generated integer token or UUID)
all references are represented in the RDBMS as a foreign key
relationship
all parent child relationships between tables are implicitly understood
to exist, although they are not stated.
all parent child relationships between tables are expressed as
references from the child to the parent via a foreign key relationship
Inventory is the relationship between an item, a warehouse, and a vendor
that has the additional properties of shelf and quantity on hand.
>From this, you see that you will need tables ITEMS (describing an item
that you keep in inventory), WAREHOUSES (describing the various
warehouses you have), VENDORS (describing your vendor info), and
INVENTORY which has references to the primary keys on the preceding
three tables.
You will also need receiving transactions (RECEIVE_TRANS) and receiving
line items (RECEIVE_LINE) that allow you to put stuff into inventory and
record it in a suitable manner that CIO''s and programmers
don''t go to
jail (See Enron). Once you have receiving in place, you need to be able
to perform the corollary work of issuing transactions (ISSUE_TRANS) and
line items (ISSUE_LINE). Finally you will need to have the capacity to
submit physical counts (PHYSCOUNT_TRANS and PHYSCOUNT_LINE).
A single transaction can only apply to one warehouse at a time, so the
TRANS record will reference the WAREHOUSE table by surrogate key.
A line item begins life as an intent to perform an operation (receive,
issue, physical count) using a COUNT of ITEMS to a WAREHOUSE at a SHELF.
All of these surrogate key references exist in the _LINE tables. After
completion and signoff on the transaction, the additional reference to
the INVENTORY surrogate key is populated.
Once you have the tables defined, build the rails classes and edit to
suit your specific business needs.
I hope this helps.