Properties in virtual graph

Hi Team,

I have created virtual graph in my system using a DB in SQL server. The graph got generated and I can query on that.
Now I extracted that graph in to a rdf/ttl format but there are certain things that I am unable to understand:

  1. All the columns defined in the database appear as annotated property rather than actual object property or data property. Because they appear as annotated property I can not execute SPARQL over the same using any other tool like Protege or TBC. Would you please help me if we can do it other way by any means?

  2. Also I can see individual instances are generated using nodes and they appear as :

 <rdf:Description rdf:nodeID="C11-2.0-1.0-27150.0-2.0-2022-08-15252000253A00253A00.0-3.5999999999999996-YES-Land-19005.0">
	<rdf:type rdf:resource="http://api.stardog.com/CustomerLoan"/>
	<Loan_Type_ID xmlns="http://api.stardog.com/CustomerLoan#" rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</Loan_Type_ID>
	<Collateral_Required xmlns="http://api.stardog.com/CustomerLoan#" rdf:datatype="http://www.w3.org/2001/XMLSchema#string">YES</Collateral_Required>
	<Collateral_Type xmlns="http://api.stardog.com/CustomerLoan#" rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Land</Collateral_Type>
	<Maturity_Date xmlns="http://api.stardog.com/CustomerLoan#" rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2022-08-15T00:00:00</Maturity_Date>
	<Cust_Loan_ID xmlns="http://api.stardog.com/CustomerLoan#" rdf:datatype="http://www.w3.org/2001/XMLSchema#string">C11</Cust_Loan_ID>
	<Bank_ID xmlns="http://api.stardog.com/CustomerLoan#" rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.0</Bank_ID>
	<Interest_Rate xmlns="http://api.stardog.com/CustomerLoan#" rdf:datatype="http://www.w3.org/2001/XMLSchema#double">3.5999999999999996</Interest_Rate>
	<Customer_ID xmlns="http://api.stardog.com/CustomerLoan#" rdf:datatype="http://www.w3.org/2001/XMLSchema#double">1.0</Customer_ID>
	<Amount xmlns="http://api.stardog.com/CustomerLoan#" rdf:datatype="http://www.w3.org/2001/XMLSchema#double">27150.0</Amount>
	<Collateral_Value xmlns="http://api.stardog.com/CustomerLoan#" rdf:datatype="http://www.w3.org/2001/XMLSchema#double">19005.0</Collateral_Value>
</rdf:Description>

Where every individual is treated as node and details attache dto those nodes are given in description. Is there any way if we can get these nodes as OWL:individual so that it becomes more generic how the rdfs/ttls are created.

Thank you!!
Best Regards,
Smrati

Hi Smrati,

I’m not understanding what you’re saying about annotation properties. This is a classification of properties that is defined in your ontology, not in the virtual graph mapping. Can you give an example of where you see this?

Regarding the individuals, each node will be treated as individual if it is not a property or class (or OWL axiom construct).

Jess

As Jess said, if the properties are treated as annotation properties, this is an issue in your ontology. Protege is based on OWL API, the type of properties has to be declared explicitly in RDF/XML, otherwise the parser would have to guess. Declaration axioms are the way to go.
By the way, even if those properties would be annotation properties, on an RDF level nothing would have been changed, thus, SPARQL would be even possible in Protege as long as you use the default SPARQL tab (which is based on RDF4J)

Hi Jess and Lorenz,
Thank you for the response. I will explain my doubt once again, I think I was not clear.

I created a virtual graph from Database and then I added generated mappings to a ttl file using:
stardog-admin virtual mappings --format r2rml myDB> myDB.ttl
Then I created a stardog DB using the same ttl file as reference as:
stardog-admin db create -n myDB myDB.ttl
Then I copied triples from DB for data using command:
stardog-admin virtual import myDB C:\startdog\data\DB.properties myDB.ttl --format r2rml
and then I extracted this stardoig DB created with data from database to a rdf file using:
stardog data export --format RDFXML myDB Database.rdf

This Database.rdf created out of stardog database(which was created automatically using stardog) has column names as annotated properties. I wanted to understand if there are any other steps that I can follow that created these column names as object and data properties in rdf generated.

Also, in the same process, each row of database table which acts as an instance of that table class, comes as description as mentioned previously. As per my understanding each row is like an instance of the table and it should come as owl:NamedIndividual, so is there any way that we can get these data as named individuals rather than as description like i am getting right now.

Thank you!

Can you give an example from the Database.rdf file which says that the column names are annotated properties?

Please find the generated Database.rdf attached.

Thanks!Database.rdf (48.8 KB)

Thanks for the data. I don’t see any annotation property characterizations here. Perhaps the RDF representation in XML is not clear? Have you tried Turtle/TTL format? Can you give a specific example of what you are calling an annotation property?

Jess

It looks the same even if I create a ttl file from the same.
If you try opening this file in Protege you will be able to see all column names as annotated properties.
Also, if you scroll down in the same file, you will be able to see description tags which should have been owl:namedIndividuals as per my understanding.

Regards,
Smrati

Protege appears to be making the assumption that these properties are annotation properties because they are not otherwise defined in your ontology. You should add object/datatype property definitions as appropriate.

Regarding OWL named individuals, this will be inferred at reasoning time.

Jess

You should add object/datatype property definitions as appropriate. : Where and how should I add object/datatype property definitions?
Regarding OWL named individuals, this will be inferred at reasoning time : I tried reasoning in Protege but it did not work. Did you mean reasoning from Stardog?
Thank you!
Regards,
Smrati

You can add the property definitions as triples like so:
<http://api.stardog.com/CustomerLoan#Loan_Type_ID> a owl:DatatypeProperty

What is not working with regard to reasoning?

Jess

Are the following steps to create an rdf/ttl/graph correct?

stardog-admin virtual add C:\startdog\data\DB.properties
–virtual graph is now created

stardog-admin virtual mappings --format r2rml DB> DB.ttl
– save the virtual graph into a turtle file

stardog-admin db create -n myDB DB.ttl
–create a db from the turtle file created above

stardog-admin virtual import myDB C:\startdog\data\DB.properties DB.ttl --format r2rml
–copy triples into the database from RDBMS

stardog-admin virtual import myDB C:\startdog\data\DB.properties DB.ttl --format r2rml
–copy triples with value and references

stardog data export --format RDFXML myDB myDB.rdf
–create RDF from the graph database

Regards,
Smrati

I don’t see any particular problems with these commands but I cannot say that it’s “correct” without know all the details of your use case and requirements. Why are you running the virtual import twice?

As i don’t have a .ttl file which has the design of the database.
First time it copies the structure or the database design. While second time using the ttl file that we get after first virtual add, it fetches data from the database and adds description tags.

I am specifically referring to these two commands:

what happens if you don't run it the second time?

Sorry, that was twice by mistake… But other than that, are all other steps right?

Regards,
Smrati

It is not necessary to do virtual import if wish to query over the relational database at runtime. Further, exporting to RDF is not necessary. Stardog stores data in indexed form and you can query directly with Stardog, including reasoning.

Jess

Regarding the property types: That’s what I said in my previous comment. In OWL properties have to be typed, otherwise, a parser is lost. Consider e.g. a dataset and a property p just used with string values, how should a parser decide on the type? Clearly, for OWL specific serialization formats like OWL Functional Syntax, Manchester Syntax this problem won’t occur as all elements are strongly typed.

Jess already provided the solution, always add triples for each schema entity.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.