有2种关系:
预测(cname,etype)
措施(etype,提供者)
cname-预计未来灾难的城市名称。
etype-事件类型。地震,海啸...
提供者-警察,救护车...
我需要使用域关系演算来编写查询,并且它应该找到一个提供程序以为Milano中的所有预测事件提供服务。
到目前为止,我已经拥有了:
{"jsonrpc":"1.0","id":"1","method":"createrawtransaction","params":["[{\"txid\":\"1a43a1f27c5837d5319a45217aa948a4d39c1d89faf497ce59de5bd570a64a26\",\"vout\":1}]","[{\"2NAZpRsvj9BstxxCDkKoe1FVjmPPxdmvqKj\":0.01}]"]}
我不确定。可以吗或有什么问题吗?
答案 0 :(得分:1)
您没有引用RA(关系代数)或DRC(域关系演算)的版本。我会从您的尝试中猜测一些语法。
-- <cname, etype> rows where city cname suffers event type etype
-- { <cname, etype> | city cname can suffer event type etype }
Provider
-- <etype, provider> rows where event type etype service is provided by provider
-- { <etype, provider> | event type etype is service is provided by provider}
Measures
为米兰的所有预测事件提供服务的提供商。
这是“ all” /“ every”的经典模棱两可的用法。如果在Milano中没有事件类型发生,您是要所有提供商还是不希望任何提供商? (这是通过关系划分的变体计算的查询中的常见问题。)
也许您想要提供商p在所有类型e的位置,如果Milano遭受e,则p服务e:
<p> rows where
(for all e (
if city 'Milano' suffers event type e then event e service is provided by p))
{ <p> | (forall e (<'Milano', e> ∈ Prediction then <e, p> ∈ Measures)) }
但是从您的查询看来,您可能希望提供商p在米兰遭受痛苦的类型以及所有类型e的情况下,如果米兰遭受e受苦,则p服务e:
<p> rows where
(for some e ('Milano' suffers event type e))
& (for all e (
if city 'Milano' suffers event type e then event e service is provided by p))
{ <p> |
(exists e (<'Milano', e> ∈ Prediction))
& (forall e (if <'Milano', e> ∈ Prediction then <e, p> ∈ Measures))
}
您的查询似乎正试图将其复杂化如下:
{ <p> |
(exists e (<'Milano', e> ∈ Prediction))
& (forall e (if <'Milano', e> ∈ Prediction
then (exists pr (<e, pr> ∈ Measures & pr = p))
}