Removing individuals & properties from RDF

owlrdfrowlexsemantic-web

I have a RDF file in my semantic web project and I use Rowlex for manipulating it.
I've needed to remove an individual from RDF, so I used

<RDFDoc instance>.RemoveIndividual(new OwlThing(<individual URI>, <RDFDoc instance>));

With this code, I had my individual gone, but it's properties still remained. So I figured out that I should remove it's properties first. Besides I didn't find a command for removing all properties together. So, Question1: is there a way to remove an individual with all it's properties? or, can I remove all properties in one line of code and not one by one? And how can I remove properties with multiple values. For instance three StudyLists, in example down page.

On the other hand, when I tried to remove a property, for example 'useSudyList' from student individual, by this code:

student.RemoveuseStudyList(student.useStudyList);

I found my RDF file:

<Ontologyowl:Student rdf:about="ehsanm">
//other properties
    <Ontologyowl:useStudyList>
        <Ontologyowl:StudyList rdf:about="stdl184516"/>
    </Ontologyowl:useStudyList>
</Ontologyowl:Student>

… became like this:

<Ontologyowl:Student rdf:about="ehsanm">
    //other properties  

</Ontologyowl:Student>
<Ontologyowl:StudyList rdf:about="stdl184516"/>

Thus the property was thrown out. I don't have this issue with literal properties. Question2: what's the problem?

Thanks for your attention, and help, in advance.

Best Answer

Your question has nothing to do with ROWLEX but it is a typical graph problem: if you delete a node, how far do you cascade the deletion? When you delete a property with a literal, the case is easy as there is no continuation of the graph. When you delete a property pointing to another node should you delete the node? Deletion in your example looks obvious because your graph contains neither circular reference, nor shared relationships.

Imagine the following graph: You have 3 persons: A (Adam), B (Bill), and their father F (Fred). You have fathership relationship between A - F and B - F. You delete relationship between Adam and his father. Should you delete the father node and bring Bill into an inconsistent (orphan :) state? The answer here is "no". You delete the relationship only.

In UML diagrams, you have the option in aggregation relationship to differentiate between "possessing" and "shared". It is expressed in the color (black or white) of the diamond at the end of the line. In relational databases, you can define or ignore "Cascade delete" over foreign keys. They represent the same concept. Unfortunately, RDF does not offer this extra metadata over a property. Had RDF have this information available, we could determine when and how far should we cascade deletion over the graph. But we don't. That sets the case up for the bad news: you are on your own, you can implement the deletion as you see fit.

Related Topic