duanjian7343 2014-05-08 13:32
浏览 19
已采纳

MySQL多表与行

I have read many posts on here about this discussion but my question is specific.

Please read in entirety before replying.

I am wondering whether it is best to have potentially hundreds if not thousands of rows in a database or to split it across multiple tables.

The scenario is: I have a user who can be in ONE AND ONLY ONE city at a time. (There are multiple cities e.g. Paris, Berlin and London) Now in each city are lots of areas (potentially several hundred). I was thinking that giving each city its own table would be more efficient.

E.G:
rooms_london
- All areas of london in here as rows
rooms_berlin
- all areas of berlin in here as rows

And so on for Paris and any other cities that I add in future.

Then in PHP I could construct a query similar to:

 SELECT * FROM rooms_$playerCity WHERE roomID = $playerRoom

Is this an efficient method or should I just add an extra column to a central rooms table.

If I've not been clear enough I will do my best to clarify anything that you need.

Many Thanks

  • 写回答

2条回答 默认 最新

  • douzhang7184 2014-05-08 13:41
    关注

    I would not split rooms into different tables.

    If performance becomes a problem I would use partitioning http://dev.mysql.com/doc/refman/5.5/en/partitioning.html

    +------+          +------+
    | City | 1 ---- * | Room |
    +------+          +------+
    

    whether ... thousands of rows in a database or to split it across multiple tables.

    performance will not be a problem before few million rows with complex queries and insufficient indexing

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效