如何在元组关系演算中表达查询?
问题:
Consider a relation of scheme Building(Street, Number, No.Apartments, Color, Age).
TRC: find the oldest building in Downing Street.
相关的 SQL 语句将是:
SELECT MAX(Age) AS ‘Oldest building’, Street FROM Building WHERE Street = ‘Downing Street’;
我使用 TRC 的答案:(B 代表 Building 关系)
{V.*|V(B) | V.BAge >=Age ^ V.Bstreet = ‘Downing Street’}
V.*
(它返回 Building 的每个单个元组)
V(B)
(它将变量 V 映射到 Building 的元组)
V.BAge >=Age ^ V.Bstreet = 'Downing Street'
(这里我设置了条件……也许……)
Problem:
Consider a relation of scheme Building(Street, Number, No.Apartments, Color, Age).
TRC: find the oldest building in Downing Street.
The associated SQL statement would be:
SELECT MAX(Age) AS ‘Oldest building’, Street FROM Building WHERE Street = ‘Downing Street’;
My answer using TRC: (B stands for Building relation)
{V.*|V(B) | V.BAge >=Age ^ V.Bstreet = ‘Downing Street’}
V.*
(it returns evry single tuple of Building)
V(B)
(it maps variables V to Building’s tuples)
V.BAge >=Age ^ V.Bstreet = ‘Downing Street’
(here I set the condition…maybe..)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这仍然相关:暗示将认识到最古老的建筑是没有其他建筑比它更古老的建筑。
If this is still relevant: the hint would be to realize that the oldest building is the one such that no other building is older than it.