Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not sure I understand your question. If you are looking for a database structure I would come up with the following 3 tables:</p> <p><strong>location</strong> (id, cityname, zipcode, country_ID)</p> <p><strong>country</strong> (id, countryname)</p> <p><strong>route</strong> (id, startlocation_ID, midlocation_ID, endlocation_ID, ratefactor)</p> <p>The final rate is probably based on a formula. The route-dependent part of the formula needs to be put into the "route" table as "ratefactor". Whether you need to put the other parts of the formula in a table, too, will depend on the formula itself (you didn't tell us enough about it). Entering of city/country names should be done with a dropdown list where the user can choose only between the ones already entered. Most of the time your users will probably use the routes tables with the already entered regular routes, I guess. If your company does serve any location in the world you can't avoid letting them enter new city names all the time themselves, of course.</p> <p><strong>UPDATE:</strong> After your EDIT I suggest you look deeper into the topic of <a href="http://en.wikipedia.org/wiki/Database_normalization" rel="nofollow">database normalization</a>. At example your "rates" table looks like you will have many, many identical routes differing only on the weight. So it would make sense to keep the route information separately as I suggested already. The additional information should go in a separate table (<strong>quote</strong>: id, route_ID, type, weight,...). </p> <p>"(feeA + feeB)" and "feeC" seem to be the ratefactors I mentioned in my suggestion. But I don't see the reason of having both feeA and feeB, because they are always added together before being used. If they refer to the price of connecting to cities and your would need to keep this information separate it would probably be best to keep the price information in a different table (<strong>connectionprice</strong>: id, locationA_ID, locationB_ID, pricing) and look it up instead of entering it every time anew.</p> <p>Although one can argue you don't need a separate PK if you have different fields whose combination makes for an unique identifier, I would make a habit of creating one ("id") for each table nonetheless. Nearly always it makes programming access and information retrieval so much easier.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload