如果三元组存储包含两次相同的三元组,那么关于这种冗余的权威立场是什么(如果存在的话)?
此外,是否应该允许三元组在同一上下文中存储两次相同的三元组?
我问这个是因为在 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]
这是作家
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"))
graph.add( ( rdflib.URIRef("http://localhost/1000"), rdflib.URIRef("http://localhost#ha"), rdflib.Literal("18")) )
graph.commit()
这是我得到的
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'>)>)