【发布时间】:2016-08-25 09:21:45
【问题描述】:
我正在学习一个在线数据库课程,我收到了这个问题。
假设我有表 USER、CHECKIN 和 PLACE。
USER(uid, uname, ucity),uid为主键。
PLACE(pid, pname, pxcoord, pycoord, pcity),pid为主键。
CHECKIN (uid, pid, cdate, ctime), (uid, cdate, ctime) 是主键。
查询是
select c.uid, c.pid c.cdate
from user u join checkin c join place p
where ucity='NewYork' and pcity='Chicago'
最多只能创建两个索引结构,最好的选择是什么,为什么?
【问题讨论】:
-
对我来说似乎是一个无效的查询。为什么我们需要无条件连接?
-
@Basilevs - 查询在 MySQL 中有效。它可能无法达到预期的效果。 stackoverflow.com/questions/16470942/…
-
这就是我的意思。城市、访问量和用户的笛卡尔积?
标签: mysql sql database database-optimization