sparql DESCRIBE查询以获取有关链接对象的数据 [英] sparql DESCRIBE query to get data about linked objects
问题描述
我已经为Books定义了rdf类. 另一个描述人的rdf类. Book类包含authoredBy字段,该字段将书本实例链接到人员实例.
I have defined a rdf class for Books. Another rdf class for describing people. The Book class contains authoredBy field which links book instances to people instances.
书籍属性
Book
-Id
-name
-authoredBy
Book
-Id
-name
-authoredBy
Person
-id
-firstName
-LastName
-designation
Person
-id
-firstName
-LastName
-designation
要检索图书属性,我使用以下sparql查询
For retrieving book properties, i use the following sparql query
DESCRIBE?书 在哪里 { ?预订rdf:Book;
DESCRIBE ?book WHERE { ?book a rdf:Book ;
}
我能够使用DESCRIBE检索属于Book的所有属性,即谓词,主语和宾语.但是,当涉及authoredBy字段时,上述查询仅向我返回作者的URI.
I am able to retrieve all the properties belonging to Book using DESCRIBE i.e the predicate , subject and object. However when it comes to authoredBy field, the above query returns me only URI of the author.
我想查看所有属于作者的谓词(即其名字,姓氏).可以修改上面的DESCRIBE查询来实现吗?
I would like to see all predicates that belong to author as well (i.e its firstname, lastname). Can the above DESCRIBE query be modified to achieve this ?
推荐答案
使用DESCRIBE属于Book的所有属性
财产不属于事物. OWL不是一种面向对象的编程语言.
Properties don't "belong" to things. OWL isn't an object-oriented programming language.
但是,您当然可以获取书籍及其作者的属性和价值. 描述查询的特定结果取决于实现.即使您使用的实现为您提供了某些结果,也无法保证其他实现会为您提供结果.使用 construct 查询更安全.就您而言,这听起来像您想要的
However, you can certainly get the properties and values of books and their authors. The particular results of a describe query are implementation dependent. Even though the implementation that you're using gives you certain results, there's no guarantee that other implementations would give you that. It's safer to use a construct query. In your case, it sounds like you want
construct where {
?book a ex:Book ;
?p ?o ;
ex:authoredBy* ?author .
?author ?ap ?ao .
}
这将返回所有书籍及其作者的所有三元组图.
That will return a graph of all the triples about all books and their authors.
我使用以下sparql查询
i use the following sparql query
DESCRIBE ?book WHERE { ?book a rdf:Book ;
}
请注意,您实际上不应该在RDF名称空间中定义自己的术语(例如,与 rdf:Book 一样).您应该为自己的类使用其他名称空间.
Note that you really shouldn't be defining your own terms in the RDF namespace (e.g., as you have with rdf:Book). You should use some other namespace for your own classes.
这篇关于sparql DESCRIBE查询以获取有关链接对象的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!