I'm playing around with the BI Server and SQL schemas and I have a few questions/issues. I'm using Stardog 8.1.1.
Issue 1
I've imported a SHACL shapes graph and a SQL schema is being generated from it since I can see the tables in a database tool. I have sql.schema.auto.source
set to shacl
. However, I'm noticing that property shapes defined for a class show up as columns only in the table for that class, but not as columns in any of the tables for subclasses of that class. For example, if I load the following TriG file:
@prefix ex: <http://example.org/> .
@prefix org: <http://www.w3.org/ns/org#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
ex:schema {
org:Organization
a owl:Class, sh:NodeShape ;
sh:property [
a sh:PropertyShape ;
sh:path org:subOrganizationOf ;
sh:maxCount 1 ;
sh:class org:Organization ;
] ;
.
org:FormaOrganization
a owl:Class, sh:NodeShape ;
rdfs:subClassOf org:Organization ;
sh:property [
a sh:PropertyShape ;
sh:path ex:officialName ;
sh:maxCount 1 ;
sh:datatype xsd:string;
] ;
.
}
ex:data {
ex:Test1
a org:Organization ;
.
ex:Test2
a org:FormalOrganization ;
ex:officialName "Test Formal Organization" ;
.
}
I get two tables, each with two columns:
-
Organization
, with columnsid
andsubOrganizationOf
-
FormalOrganization
with columnsid
andofficialName
Is that the expected behavior? I would have expected that the FormalOrganization
table to also have the subOrganizationOf
column.
Issue 2
If I go to the BI Mapping tab in Studio after uploading the above TriG file I see the following:
@prefix : <http://api.stardog.com/> .
@prefix stardog: <tag:stardog:api:> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sql: <tag:stardog:api:sql:> .
<http://www.w3.org/ns/org#OrganizationTableMapping> a sql:TableMapping ;
sql:class <http://www.w3.org/ns/org#Organization> ;
sql:tableName "Organization" .
<http://www.w3.org/ns/shacl#PropertyShapeTableMapping> a sql:TableMapping ;
sql:class <http://www.w3.org/ns/shacl#PropertyShape> ;
sql:tableName "PropertyShape" .
<http://www.w3.org/ns/shacl#NodeShapeTableMapping> a sql:TableMapping ;
sql:class <http://www.w3.org/ns/shacl#NodeShape> ;
sql:tableName "NodeShape" .
<http://www.w3.org/ns/org#FormalOrganizationTableMapping> a sql:TableMapping ;
sql:class <http://www.w3.org/ns/org#FormalOrganization> ;
sql:extends <http://www.w3.org/ns/org#OrganizationTableMapping> ;
sql:tableName "FormalOrganzation" .
There are no fields defined for these tables, but based on the documentation and this example referenced in the documentation, I would have expected fields to have been autogenerated. I have tried variations of the TriG file that all provided the same autogenerated result, including sh:targetClass
instead of implicit class targets and having the property shapes not be blank nodes.
I am able to see the expected behavior with the subOrganizationOf
column appearing in both tables if I manually create the following mapping:
@prefix : <http://api.stardog.com/> .
@prefix stardog: <tag:stardog:api:> .
@prefix ex: <http://example.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix org: <http://www.w3.org/ns/org#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sql: <tag:stardog:api:sql:> .
org:OrganizationTableMapping a sql:TableMapping ;
sql:class org:Organization ;
sql:tableName "Organization" ;
sql:hasField [
sql:property org:subOrganizationOf ;
sql:refersTo org:OrganizationTableMapping ;
sql:optional true ;
] ;
.
org:FormalOrganizationTableMapping a sql:TableMapping ;
sql:class org:FormalOrganization ;
sql:tableName "FormalOrganization" ;
sql:extends org:OrganizationTableMapping ;
sql:hasField [
sql:property ex:officialName ;
sql:optional true ;
] ;
.
Issue 3
After I use the manually created mapping, I see that the Organization
table has 1 row and the FormalOrganization
table has 1 row. Is this the expected behavior? I would have expected to see both example instances in the Organization
table, i.e. I would have expected subclass inferencing.