Home  >  Article  >  Backend Development  >  Newcomer asking for advice on the design of carpooling system

Newcomer asking for advice on the design of carpooling system

WBOY
WBOYOriginal
2016-07-06 13:51:431085browse

I’m new here, and my expressive skills are average. I hope you can be more considerate and give me more advice.
This system is different from traditional carpooling. It is based on some private fleets here (similar to bus station line buses) as a reference. Let’s think about the functions of the
system as follows:
1. Orders
2. Routes (from a certain city to a certain city, round trip)
3. Fleet (similar to user groups, classified as belonging to a certain city to a certain city) Drivers of a certain city line and sorted)
4. Drivers

The business needs based on your own observations should be as follows:
1. The user places an order to the system, and the data includes the departure city, destination city, number of people, and departure time
2. The system completes the allocation according to the following conditions:
2.1. Match the fleet belonging to the route according to the user's departure place and destination
2.2. Match the drivers currently in the current city in the fleet according to the user's departure place (according to the order of the drivers in the fleet)
2.3. Retrieve the orders assigned to the driver and count whether the total number of people in the order is greater than 4. Assume that the current driver has existing orders and the total number of people assigned by the system has reached 3 people, and the number of people in the current new order is 2. , the sum is greater than 4, then the new order will be automatically assigned to the next driver
2.4. After meeting the above conditions, the driver will be placed in the departure state

Currently, we plan to use the following format to cache the fleet and its drivers in redis

<code>array(
    array(
        'name' => '车队1',
        'route' => '1,2', // 线路所属的两个城市的id,用这种格式比较好判断
        'members' => array(
            array('司机1', '电话', 序号, 所在城市id, ...),
            array('司机2', '电话', 序号, 所在城市id, ...),
            array('司机3', '电话', 序号, 所在城市id, ...)
        )
    ),
    array(
        'name' => '车队2',
        'route' => '3,4', // 线路所属的两个城市的id,用这种格式比较好判断
        'members' => array(
            array('司机1', '电话', 序号, 所在城市id, ...),
            array('司机2', '电话', 序号, 所在城市id, ...),
            array('司机3', '电话', 序号, 所在城市id, ...)
        )
    )
    ...
);</code>

The above is all my own thinking. At first it was just to test my own skills, but now I am stuck in the order allocation process before I have gone very far. I would like to ask for some advice from an expert, whether it is a program or a database design. That's fine, thank you very much.

Reply content:

I’m new here, and my expressive skills are average. I hope you can be more considerate and give me more advice.
This system is different from traditional carpooling. It is based on some private fleets here (similar to bus station line buses) as a reference. Let’s think about the functions of the
system as follows:
1. Orders
2. Routes (from a certain city to a certain city, round trip)
3. Fleet (similar to user groups, classified as belonging to a certain city to a certain city) Drivers of a certain city line and sorted)
4. Drivers

The business needs based on your own observations should be as follows:
1. The user places an order to the system, and the data includes the departure city, destination city, number of people, and departure time
2. The system completes the allocation according to the following conditions:
2.1. Match the fleet belonging to the route according to the user's departure place and destination
2.2. Match the drivers currently in the current city in the fleet according to the user's departure place (according to the order of the drivers in the fleet)
2.3. Retrieve the orders assigned to the driver and count whether the total number of people in the order is greater than 4. Assume that the current driver has existing orders and the total number of people assigned by the system has reached 3 people, and the number of people in the current new order is 2. , the sum is greater than 4, then the new order will be automatically assigned to the next driver
2.4. After meeting the above conditions, the driver will be placed in the departure state

Currently, we plan to use the following format to cache the fleet and its drivers in redis

<code>array(
    array(
        'name' => '车队1',
        'route' => '1,2', // 线路所属的两个城市的id,用这种格式比较好判断
        'members' => array(
            array('司机1', '电话', 序号, 所在城市id, ...),
            array('司机2', '电话', 序号, 所在城市id, ...),
            array('司机3', '电话', 序号, 所在城市id, ...)
        )
    ),
    array(
        'name' => '车队2',
        'route' => '3,4', // 线路所属的两个城市的id,用这种格式比较好判断
        'members' => array(
            array('司机1', '电话', 序号, 所在城市id, ...),
            array('司机2', '电话', 序号, 所在城市id, ...),
            array('司机3', '电话', 序号, 所在城市id, ...)
        )
    )
    ...
);</code>

The above is all my own thinking. At first it was just to test my own skills, but now I am stuck in the order allocation process before I have gone very far. I would like to ask for some advice from an expert, whether it is a program or a database design. That's fine, thank you very much.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn