Page 1 of 1

Creating user-defined units of measurement..

Posted: Mon Aug 26, 2002 3:16 pm
by phpPete
I'm developing a food costing application. My client just came to me with one little add on and I'm curious as to how to build it.
The entire application is a food costing application which all 5 of the restaurants in this company will access.
The little add on is the ability to write thier own custom conversions for units of measurement.
When the user inputs a recipe they choose various ingredients, the unit of measure and the amount of the ingredient.

Example:

Code: Select all

Amount     Unit             Ingredient
8              ounce          ground beef
Now they want to be able to define a unit of measure that relates specificaly to an ingredient, however, they want to be able to use the same name multiple times.

So in one case "slice" might equate to 0.5 ounces American Cheese, whereas in another case 'slice" might equate to 6.0 ounce roast beef 1/4 inch thick.

I've sketched out a possible DB schema for this feature which looks like:

Tables

units
i_id
u_name
u_description

equivalence
eq_id
u1_id
u2_id
mulltiplier

So a possible entry might look like:

Code: Select all

Table units
u_id            u_name   u_description
001             schmear  dollop applied by knife-like utensil
002             Oz          One ounce

Table equivalence
eq_id     u1_id     u2_id   multiplier
001       001        002     2
Thus showing ( I think ) that :
1 schmear is equal to 2Oz: u1 * Multiplier == u2

Am i making any sense here?

Any input would be appreciated

Posted: Tue Aug 27, 2002 4:18 am
by mikeq
At first glance looks okay.

So is a schmear always = 2Oz or is it dependent what is being schmeared?

Posted: Tue Aug 27, 2002 5:45 am
by phpPete
A schmear can be multiple weights, dependant upon what is being schmeared.

So when the user chooses schmear from the ingredient list, the script needs to determine the correct weight for the schmeared item. Because any unit of measure will appear in the units drop down list just one time.

Pick unit of measure->
check to see if the unit "name" is user defined->
if the ingredient matches the ingredient associated with the custom unit
if yes, calculate the cost
if no create new unit of measure and calculate cost.
inseert into db
display costed item for confirmatioin

Posted: Sat Aug 31, 2002 10:26 am
by phpPete
Here's what I'm trying to develop:

Need:

A script to allow the user to define a custom unit of measurement,
to be associated with the ingredient the user is working with at that
moment, and equating to another amount of another ingredient.

Any custom conversion name may be used multiple times for
separate definitions

So a custom conversion named "Hat" when defined while working
with ground beef, is set to equal some arbitrary amount of something
else. Thus the user may define a new unit of measure using the same name
( "Hat" ) to be tied to some other ingredient. So, whenever the user
chooses "Hat" of ground beef it's different than "Hat" of avocado.

The system would then check that whenever "Hat" is chosen that "Hat":

a) is defined for the ingredient the user selected
b) choose the proper definition for the ingredient
c) make calculations based on the chosen definition


Sample DB Tables are: ( units, equivalence )

Code: Select all

Table name == units ( record one )
unit_id              001
unit_name            Schmear
unit_description     thin spread

Table name == units ( record two )
unit_id              002
unit_name            ounce
unit_description     1/16th of a pound



Table name == equivalence
equiv_id             001
unit1_id             001
unit2_id             002
bind_to              cream cheese //ingredient "in focus" when defined 
multiplier           2
The desired effect being: one schmear is equal to 2 ounce cream cheese, if the ingredient cream cheese is selected for use by the user..
So...does this appear sound?

Thanks,

Pete