开发者

Taxi service reservation system, where to start to program a start and end location?

I'm developing an application that gives the users a quick quote for the price of their travel using our limousine service.

For example, the user selects from an input where he wants to get picked up (START) and where he wants to be dropped off (END).

I hav开发者_Go百科e an excel sheet with the cross of all possible options and the allocated price for the user. ie:

             Washington   /    Airport     /  New York
Washington       0
Airport          100              0
New York         150             210              0  

How would I go about programming this?

Do I create a huge array? What structure should it have? Should I create a DB to store them? If so, what structure should I use?

Any help much appreciated.

I can use mysql or PHP or both or whatever (I don't need a user backend for this, I can change it myself in the code)/


There are libraries available for converting xls files into arrays or other formats. See phpclasses , google

Now, what you can do is pull the spreadsheet data into any data structure you understand, most likely an array. Then parse this data into a db (sqlite should suffice) with START, END and COST columns. Then when a user enters his start and end points, just use sql to fetch the cost. Hope this helps.


For a quick start I would do the following:

  • Export the spreadsheet file to a CSV file
  • Load that CSV file into an array
  • Create a lookup function that is working on the array data

That way you won't need to change the way you take care of managing the values and arrays are okay for a quick access on the data.

If the data becomes really large, a database might be better. That would change the last two points to:

  • Import the CSV file into the database
  • Create a lookup function that is working on the database data


If you're using a huge array to handle this problem you would need much php coding that might be complicated, and it wouldn't be flexible as the data get larger. So, i highly suggest you to use a database.


Use MysSQL. The number of possible combinations will grow really fast and if you use an array you will have to load all possible combinations even if you just need one(!).

MySQL offers many features to find and filter your data so you do not have to implement this yourself.

If you start with an array you will have to change a lot of code if you have to switch to a database.

EDIT: Additional pro: It makes maintaining your data a lot more easy.

If you wan to remove one stop from the list you can do it with 1 sql statement.

If you want to raise the price for pricking someone up at a specific stop you can do it with 1 sql statement.

If you want to ...


Given that most answers seem to favour a RDBMS one, I'm going to suggest a different one.

This particular solution seems well suited to be persisted and queried from a graph database. Basically you would store destinations as nodes and the cost of travel between each destination as an edge. This would allow you to traverse the graph and quickly sum up costs, even for multi-hop travel (going from Point A to B via C, D..)

The cons of this approach is that graph databases are not as ubiquitous as RDBMS ones. Your hosting provider might not be able to support or run a graph DB. You will also have to look around more to find help in solving problems here.

If you do decide on this approach, here are some links that might be helpful.

  • Neo4J/PHP - requires Java on your server
  • OQGraph Engine for MySQL - is an alternate storage engine to MySQL. requires a plugin to be installed.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜