Javadocs | API Reference
The SWKM Services: The Delete Service.
About the Delete Service.
The purpose of the Delete Service is to delete entire namespaces (including their content) from the database. The input to the service is a set of namespaces to delete, along with some parameters indicating the “mode” of the operation (details below), and the output is a Boolean flag indicating success or failure of the operation. Upon successful execution, the Delete Service removes all requested namespaces (including their content) from the database.
The Delete Service works exclusively on the persistent storage level. The service is implemented by executing SQL update operations (DELETE operations) upon the database, making sure that all the required triples, as well as all the references to the deleted namespaces are removed. More details on the effects of the Delete Service can be found in the sections that follow.
Semantics.
Contents of a Namespace.
Under the current implementation, the information on whether a triple t was inserted as part of the insertion of a namespace ns1 is not stored in the underlying representation. On the other hand, all names (for classes, properties etc) are prefixed with the URI of the namespace that they belong to, so this information is retained. As a result, the following convention is used to determine whether a triple “belongs” in a namespace: a triple t = (s,p,o) belongs to namespace n, iff it is a schema triple (i.e., its subject is a class, property, metaclass or class of properties) and its subject s belongs in namespace n.
Dependent Namespaces.
An RDF namespace may depend on declarations found in other namespaces. For instance, a property P, defined in namespace ns1 may be a subproperty of a property Q defined in a namespace ns2. In this case, we say that namespace ns1 depends on namespace ns2. More specifically, a namespace ns2 is said to be dependent of ns1 when:
- ns2 extends ns1 through subsumption (e.g., ns2#B subClassOf ns1#A)
- ns2 reuses ns1 through domain/range relation (e.g., ns2#B domain ns1#A)
- ns2 reuses ns1 through metaclass instantiation (e.g., ns2#B type ns1#A)
Dependent namespaces are important for the Delete Service, because when a namespace is deleted, then the namespaces that depend on it should be also deleted; if not, they will be rendered invalid, so the entire database will be invalid (which should not be allowed).
Deleting Namespaces.
Let us initially consider the deletion of a single namespace ns1 which has no dependents or data classified under it (directly or indirectly). This is the simplest case for the delete service. In that case, the following actions will take place:
- All the triples that belong in ns1 will be deleted from the database
- The reference to ns1 will be deleted from the database
At the end of the operation, there will be no trace of ns1 in the database. The Delete Service can, in this respect, be considered as the “complement” of the Import Service, in the sense that if we import a namespace and then delete it, the database will return to its original state; similarly, if we delete a namespace and then re-import it, the database will return to its original state. As a result, the Delete Service allows us to “undo” import operations (and vice-versa).
If the namespace ns1 depends on other namespaces, the semantics of the Delete Service is not affected (i.e., ns1 is deleted normally). This is not true if other namespaces depend on ns1 (i.e., if ns1 has dependents). In that case, the deletion of the namespace will render the database in an inconsistent state (because the dependents will be invalid), unless the dependents are deleted themselves.
To deal with this issue, the Delete Service offers two modes of execution: under the first mode, the deletion will proceed only if there are no dependent namespaces of the input namespace (and will fail if there are dependent ones); under the second mode, the Delete Service will delete the input namespace, along with all its dependent namespaces (if any).
A similar problem appears with data: data classified under a namespace will be affected by the namespace deletion and will be rendered invalid. In a sense, data classified under a namespace is a special form of a dependency. Therefore, data classified under the deleted namespace should be also deleted in order to keep the database at a consistent state. However, for data in particular, we also have the option to reclassify the data so as to be able to delete the namespace without rendering the database invalid. Reclassification is performed using the following algorithm:
- Consider an individual ‘x’ which is directly classified under the classes A1,…,An. Let us assume that the classes A1,…,Ak are contained in the namespace to be deleted (or its dependents).
- For each Ai (i=1,…,k), find the minimal (most specific) class(es) which will not be deleted (i.e., they are not parts of the deleted namespace or its dependents), let’s say Bi1,…,Bim.
- Reclassify x under Bij.
- Remove the classification links between x and Ai (i=1,…,k).
In other words, for each direct classification link xaA, where A is a class belonging to one of the namespace(s) to be deleted, reclassification finds the most specific class(es) which are superclasses of A and do not belong to one of the namespaces to be deleted, and reclassifies x under those classes, deleting the old classification links. Note that this is similar to the semantics of the Update Service (RUL) when a classification link xaA is deleted (which results to a reclassification of x to the direct superclass(es) of A). In fact, this is how the Delete Service implements the reclassification process (i.e., through calls to the RUL)
The above patterns are similarly applied if the input to the Delete Service is a set of namespace(s), rather than a single namespace. Combining the above, we conclude that the Delete Service can work under the following three modes of execution:
- Soft Delete: Under that mode, the Delete Service will fail (i.e., return false) if there are any namespaces which are not in the set of namespaces to delete, and which are depending on the namespace(s) to be deleted, or if there are any data classified under the namespace(s) to be deleted (or their dependents). In any other case, the input namespace(s) are deleted, along with their contents.
- Hard Delete with Reclassification: Under that mode, the Delete Service will delete all the namespace(s) in its input, along with all their dependent namespaces (if any). All data classified under the deleted namespaces (or their dependents) will be reclassified per the above algorithm.
- Hard Delete: Under that mode, the Delete Service will delete all the namespace(s) in its input, along with all their dependent namespaces (if any) and all data classification links pointing to any class belonging to the deleted namespaces (or their dependents). If this deletion leaves any resource unclassified, the resource is deleted altogether from the database.
Last modified: September 22, 2008