简体   繁体   English

SPARQL查询RDFS本体

[英]SPARQL query RDFS ontology

I have an RDFS ontology where i have one class Person and another class Department The class Person has a property called has_name and a property called member_of with domain Person and range Department. 我有一个RDFS本体,我有一个类Person和另一个类Department类Person有一个名为has_name的属性和一个名为member_of的属性,带有域Person和range Department。 The class Department has a property called dep_city and another called dep_name,both have domain Department and range literal. 类Department有一个名为dep_city的属性,另一个名为dep_name,它们都有domain Department和range literal。

I want to create a query so that returns the has_name value of every Person that is member_of a Department that has dep_city = "New York". 我想创建一个查询,以便返回每个Person的has_name值,该Person是member_of具有dep_city =“New York”的Department。

My question is how to connect the two classes that i need to create my query. 我的问题是如何连接我需要创建我的查询的两个类。

I can return the dep_name of all the Departments that have dep_city = "New York" 我可以返回dep_city =“New York”的所有部门的dep_name

I also know how return all the has_name of all the Persons but i don't if i can connect the two. 我也知道如何返回所有人的所有has_name,但如果我可以连接这两个人,我不知道。

Please help me Thank you!! 请帮帮我谢谢!!

I don't know what namespace you use, so I will use http://example.org/ 我不知道你使用什么命名空间,所以我将使用http://example.org/

SELECT ?name
WHERE {
    ?person <http://example.org/has_name> ?name .
    ?person <http://example.org/member_of> ?department .
    ?department <http://example.org/dep_city> "New York"
}

By the way, have you read SPARQL 1.1 Query specification? 那么,您是否阅读过SPARQL 1.1查询规范? It is a very concise document with a lot of examples 这是一个非常简洁的文档,有很多例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM