Take the 2-minute tour ×  The premise of the project is this: A
mailed package is assigned to particular courier based on its
pickup and dropoff locations. It could be FROM a specific city,
a state, a country, or a region (a group of countries, set up in
another table) and then TO any of those choice.  At this moment,
I have the package information in a table:      package_id,
pickup_city, pickup_state, pickup_country,  dropoff_city,
dropoff_state, dropoff_country.  There's also a cities table, a
countries table, a states table, and a regions table.  The way I
set up my "rules" table is to have a pickup_type
(city,state,country,region), pickup_country, pickup_location....
and dropoffs of the same.  My problems comes in when I try to
determine which rule is assigned to each package.  My initial
thought is to get the package's pickup city... loop through the
"city" type rules... if there aren't any matches, loop through
the "state" rules, then "country" rules, then "regions". If it
matches a rule, then it loops