# Properties in virtual graph

**URL:** <https://community.stardog.com/t/properties-in-virtual-graph/934>\
**Category:** Support\
**Created:** [April 18, 2018, 10:01pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934 "2018-04-18T22:01:21Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![smrati.hans](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@smrati.hans](https://community.stardog.com/u/smrati.hans)\
**Post date:** [April 18, 2018, 10:01pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/1 "2018-04-18T22:01:21Z")

</div>

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 :

```auto
 <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

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [April 19, 2018, 12:26am UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/2 "2018-04-19T00:26:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lorenz\_b](https://avatars.discourse-cdn.com/v4/letter/l/d78d45/32.png) [@lorenz\_b](https://community.stardog.com/u/lorenz_b)\
**Post date:** [April 19, 2018, 5:38am UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/3 "2018-04-19T05:38:51Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![smrati.hans](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@smrati.hans](https://community.stardog.com/u/smrati.hans)\
**Post date:** [April 19, 2018, 3:53pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/4 "2018-04-19T15:53:51Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [April 19, 2018, 4:19pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/5 "2018-04-19T16:19:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![smrati.hans](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@smrati.hans](https://community.stardog.com/u/smrati.hans)\
**Post date:** [April 19, 2018, 4:23pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/6 "2018-04-19T16:23:00Z")

</div>

Please find the generated Database.rdf attached.

Thanks! [Database.rdf](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/a3a2ef646a3d63efeda9b5fc6e6c93058becb795.rdf) (48.8 KB)

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [April 19, 2018, 4:28pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/7 "2018-04-19T16:28:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![smrati.hans](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@smrati.hans](https://community.stardog.com/u/smrati.hans)\
**Post date:** [April 19, 2018, 4:31pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/8 "2018-04-19T16:31:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [April 19, 2018, 4:43pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/9 "2018-04-19T16:43:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![smrati.hans](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@smrati.hans](https://community.stardog.com/u/smrati.hans)\
**Post date:** [April 19, 2018, 4:52pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/10 "2018-04-19T16:52:39Z")

</div>

**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

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [April 19, 2018, 4:58pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/11 "2018-04-19T16:58:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![smrati.hans](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@smrati.hans](https://community.stardog.com/u/smrati.hans)\
**Post date:** [April 19, 2018, 5:24pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/12 "2018-04-19T17:24:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [April 19, 2018, 5:49pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/13 "2018-04-19T17:49:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![smrati.hans](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@smrati.hans](https://community.stardog.com/u/smrati.hans)\
**Post date:** [April 19, 2018, 6:24pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/14 "2018-04-19T18:24:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [April 19, 2018, 8:17pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/15 "2018-04-19T20:17:12Z")

</div>

I am specifically referring to these two commands:

> [@smrati.hans](#):
>
> 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

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

---

<div class="post-metadata">

**Author:** ![smrati.hans](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@smrati.hans](https://community.stardog.com/u/smrati.hans)\
**Post date:** [April 19, 2018, 8:18pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/16 "2018-04-19T20:18:55Z")

</div>

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

Regards,  
Smrati

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [April 19, 2018, 8:24pm UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/17 "2018-04-19T20:24:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lorenz\_b](https://avatars.discourse-cdn.com/v4/letter/l/d78d45/32.png) [@lorenz\_b](https://community.stardog.com/u/lorenz_b)\
**Post date:** [April 23, 2018, 6:44am UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/18 "2018-04-23T06:44:23Z")

</div>

Regarding the property types: That's what I said in my [previous comment](https://community.stardog.com/t/properties-in-virtual-graph/934/3). 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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [May 7, 2018, 6:44am UTC](https://community.stardog.com/t/properties-in-virtual-graph/934/19 "2018-05-07T06:44:24Z")

</div>

Closed on May 7, 2018, 6:44am UTC

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