dos49618 2016-04-02 17:48
浏览 28
已采纳

用于发货路线的MySQL数据库架构,避免了复杂性[关闭]

I'm trying to build a MySQL schema for the following situation.

A book is being delivered from a locationA to locationB, through several other locations. e.g. For a book delivered from Vancouver to Los Angeles, we can go from Vancouver to Seattle to Portland to Los Angeles (Route 1), or alternatively it can take a different route from Vancouver to Calgary to Blaine to Seattle to Los Angeles (Route 2).

For every book delivered

  • I'd like to keep track of the locations it passed through.
  • I'd like to keep track of whether the book arrived at each location "on-time" or "late".

Later, when I pull up information about a given book, it's going to show the shipping route it took. Similarly, I'd be able to pull up books that were shipped through Calgary (or any other location). Also, I'd be able to show alternative shipping routes that were taken by multiple copies of the same book.

Already, a MySQL schema for this is beginning to sound very convoluted. I understand that with the proper use of foreign-keys and join-operations, we can make something work out.

However, I'm wondering whether the community can recommend a better way to organize this information. Is MySQL well-suited for this job? Should I just try to store this information on external XML files? Or should I explore a NoSQL approach? Comments would be very welcome.

  • 写回答

1条回答 默认 最新

  • dongquanjie9328 2016-04-02 20:31
    关注

    for noSql solution document structure/schema could look like:

    {
      _id:shippingIdHere,
      book:{document containing book data}
      routeInfo:[ {cityId(or just name), timeStamp, isOnTime}]
    }
    

    The document will contain an array of route info data - city, time, and indicator of on time route. Then there will be a need to add an index on routeInfo fields to get what's needed faster.

    I see no issues with MySQL as this can be done by creating a table like this

    rowID|shipingId|bookId|cityId|isOnTime|timeStamp

    and making a view will do the job.

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

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置