Solved

How should I organize categories and their territory rates into Access tables?

Posted on 2016-08-30
13
36 Views
Last Modified: 2016-08-30
I don't know why, but I've been staring at this problem for a while now and I can't see it clearly.  Could someone please help me figure out how to set up the Access tables for this type of data?

I need users to be able to pick a Specialty Class, then pick a Location to find the Rate.  Each location is associated with a particular Territory.  Each Territory has a given Rate for each Specialty Class.  

For example,
   I have Locations: AL in T1, TX in T1, OK in T1, CA in T2, LA in T2, NY in T2, OR in T3, WY in T3, NC in T3, etc.
   I have Specialty1, Specialty2, Specialty3, etc.
   I also have Specialty1 T1 Rate, Specialty1 T2 Rate, Specialty1 T3 Rate, Specialty2 T1 Rate, etc.

I've tried combinations of tables ranging from 2 to 4.  But I can't seem to come with something logical that will allow the user to pick the Specialty Class, pick the Location, and then view the Rate (or drop the rate into a calculation).

Any ideas of how this is normally done?

Thanks!
0
Comment
Question by:fabi2004
  • 6
  • 4
  • 3
13 Comments
 
LVL 26

Assisted Solution

by:Nick67
Nick67 earned 250 total points
ID: 41777163
Ok.
Start here
http://phlonx.com/resources/nf3/
Go through it all.

Now, stop thinking about the users and the UI for a bit and think about the data.
What stuff is fully independent?
There are territories.
There are locations.  Each location belongs to one and only one territory
There are Specialty Classes.
There are rates.  Each rate depends upon a specialty class and upon a territory.

Four tables.
Likely, once you get them built with their relationships that you'll want to have three cascading dropdowns.
There's a Territories one.  It cascades to limit the choices for a Location one.
The Territory one cascades to limit the choices for the Specialty Classes, too.
Choose the Specialty Class, and the related rate can then be displayed.

But you may have gone awry in not thinking about picking the territory.
The territory is what limits the choices of locations, and specialty classes.
Those two things then determine the rate.
0
 
LVL 84
ID: 41777172
Does the combination of a specific Specialty + Location determine the Rate? And you want the user to select a Specialty, and then a Location, and you would then want to lookup the Rate?

Is a specific Rate dependent on the Specialty + Location? In other words, if I have a Specialty of XX, is the rate different for LocationA versus LocationB? Or is it different for TerritoryA versus TerritoryB?

Might help if you could provide some sample data (obfuscated, of course).
0
 
LVL 1

Author Comment

by:fabi2004
ID: 41777189
Scott, each Territory + Specialty has a Rate.  There are only four territories and each of them contains many parts of the country.  A user wouldn't automatically know the territory, but they would know the specialty category and the location which they could use to look up the territory.  Then, the territory + specialty combination would pinpoint the rate.

Thank you Nick.  I'm going to look through that and try it.

The sample data I have is in an Excel workbook.  The workbook calculations need to become a part of the database I'm building.  Should I upload the workbook?
0
 
LVL 1

Author Comment

by:fabi2004
ID: 41777204
OK Nick, I was thinking four tables at one point also.  But 2 of the four tables will only have a column, two at most.

For example, the Territory table only needs a PK with territory numbers 1-4.  Nothing else.  

The Specialty Classes table doesn't need anything other than a PK (probably autonumber) and the SpecialtyClass description.

So, when I go with four tables, I feel like I'm adding unneeded complexity.  However, when I go with two tables, tblLocations and tblRates, I end up with a many-to-many relationship based on Territory.

Trying with 3 tables, tblLocations, tblRates, tblTerritories confuses me on looking up the rate.

BTW...a user would not automatically know the territory.  They would know the location and that would need a lookup for territory.  Also, each specialty has a rate for each territory.  So specialty 1 territory 1 = UniqueRate, Specialty 1 Territory 2 = UniqueRate2

Sometimes it seems so hard to explain things verbally (or in written form in this case) :-)
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 41777213
So a Location would belong to one and only one Territory?

If so, then something like this to start off:

tSpecialty
---------------
ID
Specialty

tLocation
----------------
ID
Territory_ID
Location

tTerritory
-----------------
ID
Territory

tTerritory_Rates
-------------------------
Territory_ID
Specialty_ID
Rate
Rate_Name

The user would select a Specialty and a Location, and you could then use something like this to get the Rate:

SELECT * FROM tTerritory_Rates AS tr INNER JOIN tLocation loc ON tr.Territory_ID=loc.Territory_ID
WHERE tr.Specialty_ID=" & SomeSpecialtyIDValue & " AND loc.ID=" & SomeLocationIDValue
0
 
LVL 1

Author Comment

by:fabi2004
ID: 41777228
Alright, that was basically my four table setup other then the rate name, which doesn't exist.  So you think this is the best way to set it up?  When I looked at it, it seemed I was creating extra table with little to no data in them.  But then, when I tried to combine some data into fewer tables, I ran into more complexity when looking up the rate.
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 84
ID: 41777243
You don't have to create lookup tables (the Territory and Specialty tables, for example), but in general it's a good idea to do so. Without those types of tables you would find it difficult to add new Territories or Specialties - and you'd also find it difficult to create reports when you get to that phase of the project.

And you shouldn't really be concerned with the number of tables, but rather whether those tables are correctly structured. Given the information provided, it would seem the structure I suggested would be a good starting point. That doesn't mean it's the best (or even the right) structure - but it's just a common structure for the business processes you've explained.
0
 
LVL 1

Author Comment

by:fabi2004
ID: 41777248
Excellent.  I feel better moving forward with it like this.  I so much appreciate both of you for helping me.  Thank you so much.
0
 
LVL 1

Author Closing Comment

by:fabi2004
ID: 41777252
Thank you Nick.  Than you Scott.
0
 
LVL 26

Expert Comment

by:Nick67
ID: 41777294
OK Nick, I was thinking four tables at one point also.  But 2 of the four tables will only have a column, two at most.

When you start to think about it, you may START with only one or two columns -- but good data has a tendency to grow.

Take Territory.
It will have an ID
Probably a friendly name
It was created by somebody
It was created on a certain date
It can have a notes field so you can write some stuff about how and why that territory came to exist
It can have an date last edited field ( maybe one state moves from one territory to another based on workload or distributions centers or something)

Locations may be similar

Take rates (I take it prices)
Those get really tricky.
Who created them, where they applied, start times and end times that they were in effect are just some of the things you may want to record.

Lots of data can add up quickly when you start to put it into production and track changes!
But if you get a good, solid normalized data setup going FIRST extending it later is much easier.
Take a shortcut early and you comes to painfully regret it later.
0
 
LVL 26

Expert Comment

by:Nick67
ID: 41777301
BTW...a user would not automatically know the territory.  They would know the location and that would need a lookup for territory.

Good enough.  You can create a flat listing of locations -- but don't sell the users short, or forget about good UI design.  
1. If you give the territory a friendly name, and choosing it shortens up the list of locations, the user won't take long to know what territory they are in.
2. Humans--and comboboxes -- are visually good with about 30 things in a dropdown listing.  If you have a lot more than 30 locations, having the user select a territory first so that the location dropdown has a lot fewer items in it makes their lives much easier.  Hunting for something at the bottom of a long combobox dropdown when you are not a typer stinks and is not efficient design.

Thank you Nick.  Thank you Scott.
You're welcome.
0
 
LVL 1

Author Comment

by:fabi2004
ID: 41777312
Thank you so much for the explanation.  Everything makes perfect sense.  I appreciate your time.
0
 
LVL 26

Expert Comment

by:Nick67
ID: 41777329
You're welcome.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now