【发布时间】:2011-09-13 04:10:29
【问题描述】:
我正在为我的垃圾收集公司开发路线跟踪/优化软件,希望对我当前的数据结构/情况提供一些反馈。
这是我的 MongoDB 结构的简化版本:
数据库:数据
收藏:
“客户” - 包含所有客户数据的数据集合。
[
{
"cust_id": "1001",
"name": "Customer 1",
"address": "123 Fake St",
"city": "Boston"
},
{
"cust_id": "1002",
"name": "Customer 2",
"address": "123 Real St",
"city": "Boston"
},
{
"cust_id": "1003",
"name": "Customer 3",
"address": "12 Elm St",
"city": "Boston"
},
{
"cust_id": "1004",
"name": "Customer 4",
"address": "16 Union St",
"city": "Boston"
},
{
"cust_id": "1005",
"name": "Customer 5",
"address": "13 Massachusetts Ave",
"city": "Boston"
}, { ... }, { ... }, ...
]
“卡车” - 包含所有卡车数据的数据集合。
[
{
"truckid": "21",
"type": "Refuse",
"year": "2011",
"make": "Mack",
"model": "TerraPro Cabover",
"body": "Mcneilus Rear Loader XC",
"capacity": "25 cubic yards"
},
{
"truckid": "22",
"type": "Refuse",
"year": "2009",
"make": "Mack",
"model": "TerraPro Cabover",
"body": "Mcneilus Rear Loader XC",
"capacity": "25 cubic yards"
},
{
"truckid": "12",
"type": "Dump",
"year": "2006",
"make": "Chevrolet",
"model": "C3500 HD",
"body": "Rugby Hydraulic Dump",
"capacity": "15 cubic yards"
}
]
“驱动程序” - 包含所有驱动程序数据的数据集合。
[
{
"driverid": "1234",
"name": "John Doe"
},
{
"driverid": "4321",
"name": "Jack Smith"
},
{
"driverid": "3421",
"name": "Don Johnson"
}
]
“路由列表” - 包含所有预定路由列表的数据集合。
[
{
"route_name": "monday_1",
"day": "monday",
"truck": "21",
"stops": [
{
"cust_id": "1001"
},
{
"cust_id": "1010"
},
{
"cust_id": "1002"
}
]
},
{
"route_name": "friday_1",
"day": "friday",
"truck": "12",
"stops": [
{
"cust_id": "1003"
},
{
"cust_id": "1004"
},
{
"cust_id": "1012"
}
]
}
]
“路线” - 包含所有活动和已完成路线的数据的数据集合。
[
{
"routeid": "1",
"route_name": "monday1",
"start_time": "04:31 AM",
"status": "active",
"stops": [
{
"customerid": "1001",
"status": "complete",
"start_time": "04:45 AM",
"finish_time": "04:48 AM",
"elapsed_time": "3"
},
{
"customerid": "1010",
"status": "complete",
"start_time": "04:50 AM",
"finish_time": "04:52 AM",
"elapsed_time": "2"
},
{
"customerid": "1002",
"status": "incomplete",
"start_time": "",
"finish_time": "",
"elapsed_time": ""
},
{
"customerid": "1005",
"status": "incomplete",
"start_time": "",
"finish_time": "",
"elapsed_time": ""
}
]
}
]
到目前为止的过程如下:
司机每天都从开始一条新路线开始。在开始新路线之前,司机必须先输入数据:
- 驱动程序ID
- 日期
- 卡车
正确输入所有数据后,开始新路线:
- 在集合中创建新对象“路由”
- “day” + “truck” 的查询集合 “route-lists” 匹配并返回 “stops”强>
- 将“route-lists”数据插入“routes”集合
随着司机进行他的日常停靠/任务,“路线”集合将相应更新。
完成所有任务后,驾驶员只需将“路线”集合中的“状态”字段从“完成”更改为“活动”即可完成路线流程。
总结一下。非常感谢任何反馈、意见、cmets、链接、优化策略。
提前感谢您的宝贵时间。
【问题讨论】:
标签: mongodb database-design database