views:

83

answers:

2

Hello, 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.

+2  A: 

You did remove the property, however there were other statements related to <stdl184516> which you didn't remove.

Here are the actual statements you have (Turtle format):

<ehsanm> a Ontologyowl:Student .
## Other statements
<ehsanm> Ontologyowl:useStudyList <stdl184516> .
<stdl184516> a Ontologyowl:StudyList .

So it makes sense that the removal of the Ontologyowl:useStudyList predicate for your <ehsanm> subject (and the statement which contains it) would leave the remaining assertion regarding <stdl184516>'s type.

The reason why you don't have this problem with literals is that you have no literals as subjects of a statement (they are only objects of a statement). So removing that statement removes the literal (and all references to it). With resources as a statement's object, there could be additional statements regarding that resource (as is the case in your example).

RDF considers literals disjoint, meaning they are all different (even if they have the same value). This why removing a predicate to a literal (the "link" to it if you want to think of it that way) also removes the literal.

Update (to add to Mr. Lame's response): Conceptually, RDF is about edges (relations/predicates) in a graph of nodes (resources). The notion of deleting a node is contrary to RDF; it implies the node (resource) has meaning on it's own. Even typing a resource by asserting its rdf:type is a node/edge/node statement. The node URI alone is considered opaque and has no semantics beyond being a unique identifier. This is why RDF does not allow "bare" nodes (a node outside of a statement) -- they have no inherent meaning.

To extend the question posed by Ehsan, deleting a node would actually delete all of its incoming/outgoing predicates. This doesn't truly "delete" the node, it actually removes all statements/assertions which reference it (think of it as "hidden" when no statements reference it).

Phil M
Thank you very much for guidance. I will Check again and add some code to see if it works.Thanks again
Ehsan
+1  A: 

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.

Mr. Lame
You nailed the point!
ROWLEX Admin
Thank you very much for this very helpful reply. But, this made me another question. I've posted that by this title: "Individuals and properties in semantic web". I would appreciate it much, if you take a look at that.Thank you again
Ehsan