我目前正在创建一个表来存储出租车预订。
键
Id - booking id
CustId - id of customer who is being picked up
DriverId - id of driver who is picking up customers
PickupAddr - pickup location
PickupLat - lat coordinate of pickup location
PickupLon - lon coordinate of pickup location
DropoffAdr - drop off location
DropoffLat - lat coordinate of dropoff location
DropoffLon - lon coordinate of dropoff location
Mileage - distance between PickupAddr and DropoffAddr, including any other stops made
Stops - number of waypoints/stops during journey
Price - what this customer has to pay for this part in the journey
我目前面临的问题是我不知道如何处理航路点。
例如如果您已在A接您前往B,但决定在旅途中在A1和A2停下来接一些 friend (当然都是提前预订的)
重组当前表格以适应这种情况的最佳方式是什么?
它应该作为单独的行还是列?由于这些数据是动态的(即无法预测客户在旅程中的接送次数),我应该实现什么目标。
最佳答案
由于这是一对多关系,因此它应该是一个单独的表:
id
- 航点 IDbooking_id
- FK 到booking
表sequence
- 行程中此航点的顺序addr
- 航点地址lat
- 航路点的纬度long
- 航路点的经度
如果需要,您可以从 bookings
表中删除 PickupXXX
和 DropoffXXX
列,而只需使用航点表即可。上车可能是第一个路径点,下车可能是最后一个路径点。
关于mysql - 在 SQL 表中容纳航路点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24981100/