对于公交车时刻表,我应该为所有公交车创建一个数据表并将时间表存储在一列中,还是为每条公交车创建单独的表?
我只需要能够显示接下来几辆巴士的到达时间,不打算做任何旅行计划。
对于数据库来说,将每条路线的所有时间都放在一个条目中可能会更快,对吗?尽管这意味着无论日程安排如何,即使他们只需要一些,也需要获得全部内容。
哪种方式会更有效率?
I just need to be able to display the arrival times of the next couple buses, don't plan on doing any trip planning.
Having all the times for each route in a single entry would probably be faster for the database right? Although that would mean whatever's pulling schedules would need to get the whole thing even if they just need a few.
Which way would be more efficient?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的形式是,您需要三张表:一张用于您的公交车,一张用于站点,一张用于时刻表。
前两个表是不言自明的。以下是第三张表的示例,该路线具有三个站点,其中一趟在早上运行,一趟在晚上运行:
In the simplest form, you need three tables: one for your buses, one for their stops, and one for the timetables.
The first two tables are self-explanatory. Here is an example of the third table for a route with three stops that makes one run in the morning and one run in the evening:
当您乘坐第三辆(或更多)公交车时会发生什么?我将创建一个总线表,以通过外键从主路由表中引用。
HTH,巴德
What happens when you get the third bus (or more)? I would create a bus table to reference from a main table of routes via foreign key.
HTH, Bud