MySQL-SQL and Relational Algebra queries
This section asks you to write some queries in Relational Algebra and SQL.Your SQL queries will be graded by running them in MySQL on test cases; queries that return the wrong answer will receive 0 points, i.e. there is no partial credit. In particular, please make sure your query returns the right column(s).
Consider the schema given by the following two SQLCREATEstatements.
CREATE TABLE SuppInfo (suppid INTEGER NOT NULL,
prodid INTEGER NOT NULL,
PRIMARY KEY (suppid, prodid));
CREATE TABLE Purchases (purchaseid INTEGER PRIMARY KEY,
custid INTEGER,
prodid INTEGER,
purchasemethod INTEGER);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
relational algebra这么高深的玩意就不做了.
mysql:
题一:
select prodid, group_concat(suppid) from SuppInfo group by prodid;
题二:
select custid from Purchases group by custid having count(distinct purchasemethod)>1;
select custid from Purchases P1 where exists (select 1 from Purchases P2 where P1.purchasemethod <> P2.purchasemethod );