RDF中的重复三元组,权威视图?

RDF中的重复三元组,权威视图?,rdf,triplestore,Rdf,Triplestore,如果一个三元组存储包含两倍于同一个三元组的数据,那么关于这种冗余的权威立场是什么(如果有的话) 此外,是否应该允许triplestore在同一上下文中存储两次相同的triple 我这样问是因为在rdflib中,显然可以将同一个三元组存储两次(或更多)。这是读者 import rdflib from rdflib import store s = rdflib.plugin.get('MySQL', store.Store)('rdfstore') config_string = "host=

如果一个三元组存储包含两倍于同一个三元组的数据,那么关于这种冗余的权威立场是什么(如果有的话)

此外,是否应该允许triplestore在同一上下文中存储两次相同的triple

我这样问是因为在rdflib中,显然可以将同一个三元组存储两次(或更多)。这是读者

import rdflib
from rdflib import store

s = rdflib.plugin.get('MySQL', store.Store)('rdfstore')

config_string = "host=localhost,password=foo,user=foo,db=foo"
rt = s.open(config_string,create=False)
if rt != store.VALID_STORE:
    s.open(config_string,create=True)

graph = rdflib.ConjunctiveGraph(s, identifier = rdflib.URIRef("urn:uuid:a19f9b78-cc43-4866-b9a1-4b009fe91f52"))
rows = graph.query("SELECT ?id ?value { ?id <http://localhost#ha> ?value . }")
for r in rows:
    print r[0], r[1]
这是我得到的

sbo@dhcp-045:~/tmp/gd $ python ./reader2.py 
table kb_7b066eca61_relations Doesn't exist
table kb_7b066eca61_relations Doesn't exist
sbo@dhcp-045:~/tmp/gd $ python ./reader2.py 
sbo@dhcp-045:~/tmp/gd $ python ./reader2.py 
sbo@dhcp-045:~/tmp/gd $ python ./writer2.py 
sbo@dhcp-045:~/tmp/gd $ python ./reader2.py 
http://localhost/1000 18
sbo@dhcp-045:~/tmp/gd $ python ./writer2.py 
sbo@dhcp-045:~/tmp/gd $ python ./reader2.py 
http://localhost/1000 18
http://localhost/1000 18
对我来说,这似乎是一个错误。一个修改过的版本告诉我,两个三元组都属于同一个上下文,实际上也有两个三元组

len : 2
http://localhost/1000 18
http://localhost/1000 18
(rdflib.URIRef('http://localhost/1000'), rdflib.URIRef('http://localhost#ha'), rdflib.Literal(u'18'), <Graph identifier=urn:uuid:a19f9b78-cc43-4866-b9a1-4b009fe91f52 (<class 'rdflib.Graph.Graph'>)>)
(rdflib.URIRef('http://localhost/1000'), rdflib.URIRef('http://localhost#ha'), rdflib.Literal(u'18'), <Graph identifier=urn:uuid:a19f9b78-cc43-4866-b9a1-4b009fe91f52 (<class 'rdflib.Graph.Graph'>)>)
len:2
http://localhost/1000 18
http://localhost/1000 18
(rdflib.URIRef('http://localhost/1000'),rdflib.URIRef('http://localhost#ha'),rdflib.Literal(u'18'),)
(rdflib.URIRef('http://localhost/1000'),rdflib.URIRef('http://localhost#ha'),rdflib.Literal(u'18'),)

RDF三元组存储是一组三元组,因此根据定义,同一个三元组不能出现两次。然而,大多数rdf存储实际上是四元存储(rdf图集也称为数据集),在这种情况下,三元存储可能会出现多次。这有时称为上下文,具体取决于存储(如我的)。用户有权定义特定图形名称/上下文名称的含义。

RDF是一种表达事实主张的语言,它被组织并分组到图形中。如果一个图表包含两次“Alice是一个人”,那就是多余的。所以在一个图中,三元组是标准化的;重复这些是没有意义的。然而,应用程序、商店和SPARQL可查询系统通常会从不同的来源收集事实索赔。SPARQL语言有一个“GRAPH”关键字,用于从多个图形的角度在不同的源中查找同一个三元组。

应该记住,任何特定的三元组可能具有不同于其他三元组的元数据(否则相同)。元数据,如三元组的原始源、连接信息的可能强度等。仅仅计算一个三元组的拷贝数也可能是可行的,以便判断一个连接相对于其他可能的矛盾连接的相对强度。因此,一如既往,这一切都取决于您打算如何处理数据

这也是我的想法,但显然我在rdflib中发现了一个bug,因为我一次又一次地推同一个三元组,结果得到了重复的结果。“Alice是一个人”声明两次可能是多余的,但是“Alice呼叫Bob”声明两次又如何呢。难道这不能告诉我“爱丽丝打电话给鲍勃”在两个不同的场合吗?什么才是正确的表达方式。
len : 2
http://localhost/1000 18
http://localhost/1000 18
(rdflib.URIRef('http://localhost/1000'), rdflib.URIRef('http://localhost#ha'), rdflib.Literal(u'18'), <Graph identifier=urn:uuid:a19f9b78-cc43-4866-b9a1-4b009fe91f52 (<class 'rdflib.Graph.Graph'>)>)
(rdflib.URIRef('http://localhost/1000'), rdflib.URIRef('http://localhost#ha'), rdflib.Literal(u'18'), <Graph identifier=urn:uuid:a19f9b78-cc43-4866-b9a1-4b009fe91f52 (<class 'rdflib.Graph.Graph'>)>)