以下是我的 2 张桌子:
CREATE TABLE Tree (
"id" integer NOT NULL, -- Primary key
"tags" varchar(500),
"rootNode" integer NOT NULL -- Referes to Node table's "id"
);
CREATE TABLE Node (
"id" integer NOT NULL, -- Primary key
"parent" integer NOT NULL,
"owner" varchar(500),
"data" varchar(500),
"tags" varchar(500)
);
我为这些创建的通用 RDF 文件如下:
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:wp="http://example.com/dm#">
<wp:WPS rdf:about="http://example.com/">
<wp:node><rdf:Description> <wp:id>0</wp:id><wp:parent>-1</wp:parent><wp:owner>Kumar</wp:owner><wp:data>--#ABCDEFGHIJKLMNOPQRSTUVWXYZ#--</wp:data><wp:tags>MyTag</wp:tags></rdf:Description></wp:node>
.....
<wp:tree><rdf:Description> <wp:treeId>814</wp:treeId><wp:treeTags>Banking</wp:treeTags><wp:rootNode>19989</wp:rootNode></rdf:Description></wp:tree>
.......
</wp:WPS></rdf:RDF>
这是为这两个表创建组合 rdf 文件的正确方法吗?
现在我想运行类似于以下 SQL 查询的 SPQRQL 查询:
select w.id, w.tags, w.owner from Node w, Tree t where t.id=100;
我尝试使用 FILTER 使用以下查询,但无法获得所需的结果。这样做的正确方法是什么?
PREFIX wp: <http://example.com/dm#>
SELECT ?x ?id
WHERE {
?x wp:id ?id .
?x wp:trailId ?trailId .
?x wp:rootWP ?rootWP .
FILTER (?trailId = 100)
FILTER (?rootWP = ?id)
}