• I set up a new stardog database in Studio
• I created a new virtual connection to a postgres database (confirmed accessible)
• Autogenerated the mappings (see Section 1 below)
• My SPARQL query focusses on two very simple tables than join on one column
• SQL table layouts (see Section 2 below)
• I’ve tried so many types of SPARQL queries but no results
• Table data is very small (see Section 3)
• I went through the examples on Mapping Data Sources | Stardog Documentation Latest
Here are two queries that return no results:
SELECT * {
GRAPH virtual://dgr_vir {
?rk a :role ;
:role_key_integer 2 .
}
}
SELECT * {
GRAPH virtual://dgr_vir {
?role_permission :permission_key_integer 2 .
}
}
Is the is a default/named graph issue?
Section 1
MAPPING
FROM SQL {
SELECT *
FROM "public"."role_permission"
}
TO {
?subject http://api.stardog.com/role_permission#permission_key ?permission_key_integer .
?subject http://api.stardog.com/role_permission#ref-permission_key ?ref_permission_key .
?subject http://api.stardog.com/role_permission#ref-role_key ?ref_role_key .
?subject http://api.stardog.com/role_permission#role_key ?role_key_integer .
?subject http://api.stardog.com/role_permission#role_permission_key ?role_permission_key_integer .
?subject http://api.stardog.com/role_permission#updated_by_user_code ?updated_by_user_code .
?subject http://api.stardog.com/role_permission#updated_on_date_time ?updated_on_date_time_dateTime .
?subject rdf:type :role_permission
} WHERE {
BIND(StrDt(?permission_key, xsd:integer) AS ?permission_key_integer)
BIND(StrDt(?role_key, xsd:integer) AS ?role_key_integer)
BIND(StrDt(?role_permission_key, xsd:integer) AS ?role_permission_key_integer)
BIND(StrDt(?updated_on_date_time, xsd:dateTime) AS ?updated_on_date_time_dateTime)
BIND(template("http://api.stardog.com/permission/permission_key={permission_key}") AS ?ref_permission_key)
BIND(template("http://api.stardog.com/role/role_key={role_key}") AS ?ref_role_key)
BIND(template("http://api.stardog.com/role_permission/role_permission_key={role_permission_key}") AS ?subject)
}
MAPPING
FROM SQL {
SELECT *
FROM "public"."role"
}
TO {
?subject http://api.stardog.com/role#role_key ?role_key_integer .
?subject http://api.stardog.com/role#role_name ?role_name .
?subject http://api.stardog.com/role#updated_by_user_code ?updated_by_user_code .
?subject http://api.stardog.com/role#updated_on_date_time ?updated_on_date_time_dateTime .
?subject rdf:type :role
} WHERE {
BIND(StrDt(?role_key, xsd:integer) AS ?role_key_integer)
BIND(StrDt(?updated_on_date_time, xsd:dateTime) AS ?updated_on_date_time_dateTime)
BIND(template("http://api.stardog.com/role/role_key={role_key}") AS ?subject)
}
Section 2
CREATE TABLE role (
role_key BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
role_name CHARACTER VARYING(100) NOT NULL,
updated_by_user_code CHARACTER VARYING(20) NOT NULL,
updated_on_date_time TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL,
CONSTRAINT role_pk PRIMARY KEY (role_key),
CONSTRAINT uq_role_name UNIQUE (role_name));
CREATE TABLE role_permission
(role_permission_key BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
role_key BIGINT,
permission_key BIGINT,
updated_by_user_code CHARACTER VARYING(20) NOT NULL,
updated_on_date_time TIMESTAMP(6) WITHOUT TIME ZONE NOT NULL,
CONSTRAINT role_permission_pk PRIMARY KEY (role_permission_key),
CONSTRAINT permission_fk FOREIGN KEY (permission_key) REFERENCES "permission" ("permission_key") ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT role_fk FOREIGN KEY (role_key) REFERENCES "role" ("role_key") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT uq_role_perm UNIQUE (role_key, permission_key));
Section 3
role table
role_permission