首页 > 试题广场 >

有关系模式:User(userId, userName),

[问答题]
有关系模式:User(userId, userName), Article(articleId, userId, title,   content),
Vote(articleId, score),User为用户关系,Article为用户发表的文章关系,Vote为文章得票
关系,title为文章标题、score为得票数。
(1)用SQL语言查询所有没发表过文章的用户名;
(2)用SQL语言查询得票数大于100的所有文章标题,按得票数倒序排列;
(3)用SQL语言查询出发表文章数大于5,文章平均得票数大于100的用户名,按平均得票数倒序排列;
(4)设计这些表的主键、外键和索引,并指出上面三个查询所使用的索引。
(5)当用户数超过1000万,文章数超过1亿时,如何考虑存储及性能的改进和优化?
(1)select  userName from User where userld not in(select userld from Article);
(2)select a.title ,count(b.score)num from Article a,Vote b  where a.articleld =b.articleld and b.score>100 group by a.title order by num desc;
(3)慢慢推理找到三表之间的桥梁去分析;
(4)primary key ,create   index index_name   on 表(字段);  
(5)hadoop 或者spark,都比较快,mysql处理就太慢了,集群简单测试一亿数据,hive只需要5分钟,mysql 12个小时,爬坑。。。。
发表于 2015-11-10 22:04:51 回复(0)