duanguai2781 2018-07-31 20:25
浏览 27
已采纳

too long

I am developing Bus Reservation System but i am stack on how to implement this situation.

I will use this funny example of countries so you can get an idea.

A Bus main Route is from USA To China but it have some stop points like England, India and Russia.

Main Route USA To CHINA

Sub-Route USA To ENGLAND ENGLAND To INDIA INDIA To RUSSIA RUSSIA To CHINA

The logic i need a help to implement is

  1. if a Passenger board from USA and off board in England sat on A1 seat what logic should i use when another passenger want to book the same seat A1 from England to India or Russia???
  2. I need advice which logic should i use when a seat B1 lets say was booked from England to China what logic should i use when passengers from India & Russia to China to show them that seat B1 is booked.

I tried to brainstorm this situation whole day without any success. Need help guys.

  • 写回答

1条回答 默认 最新

  • doushu0591 2018-07-31 20:51
    关注

    Instead of thinking of reservations being for a whole trip, instead think of reservations being for each step of the trip.

    Lets say your bus route is: USA to Russia to China to England to India. If i book a seat from USA to India then in your system treat it like I booked 4 trips with the same seat.

    Someone might book B1 England to India, then if I want B1 for USA to india, I should be able to see that it is only available for USA to England. I would need to book a different seat for England to India or go on a different day if they are all full.

    Here is a very, very, very basic DB concept:

    • Trips: have many steps
    • id, name, date

    • steps_trips: lookup table

    • id, step_id, trip_id

    • Steps: have many trips

    • id, startpoint, endpoint, start_time, end_time

    • busses_steps: lookup table

    • id, buss_id, step_id

    • Busses: have many seats, have many steps

    • id, name, vin

    • Seats: belongs to busses

    • id, name, buss_id

    So the idea here is that you might have several busses running several different routes. A traveler can pick a trip then your system can choose the busses and seats based on availability and time.

    This is a very involved problem so I suggest starting small the building up. You will need a way to handle reserved seating as well as cancelations, and it would be a good idea to present the available seats visually somehow in your system as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失