The reasons to decompose and store a Prolog program in RDBMS are:
The same communication method, which is SQL, is used to create, alter or delete both extensional and intensional data.
The decomposition and storing a program in RDBMS addresses a more general problem which is how to represent knowledge. This issue is out of the scope of this dissertation but it is widely discussed in [27,11,12,14,13,10,9].
Summarizing:
|
The ER diagram visualizing the decomposition is given in Figure 8.1. The program is targeted by the goal which is given as a predicate denoted by predicate and arity. Each program consists of some number of ordered clauses. The order of clauses is provided by clause order.
Each complex clause is composed of the head and the body. The head is a predicate name, denoted as name (clause entity) and a list of parameters, denoted as argument entity. Each of the parameters has a name and position.
The body consists of some number of ordered subgoals (preconditioned relationship). Each subgoal is described by clause entity. The subgoals are separated by logical operators (logical operator entity), which are a comma (',') or a semicolon (';'). Additionally, there should be two more operators defined: an implication (denoted as ':-', which is equivalent to ) to separate the head and the body, and a period ('.') at the end of the complex clause.
For example, having the following complex clause (it is the first clause from Figure 6.2):
sibling(X,Y) :- parent(X,Z), parent(Y,Z), X \== Y.It will be decomposed into the relations given in Table 8.1. The decomposition process is visualized in Figure 8.2.
The program could be decomposed further covering non-atomic values of parameters: structures and lists. But having a parameter which is a structure, it is allowed that such a structure has some parameters which could also be structures, and so on. Such decomposed parameters will require a recursive query, to follow all the subsequent parameters: parameters which are structures, which have parameters which are structures, and so on. It may have tremendous impact on the performance. And this is the reason why parameters of predicates are not subject to further decomposition.
A parameter may be a structure or list but it will be decomposed as an atomic one. Summarizing: constants, variables, structures and lists are all perceived as atomic arguments, so there will be a single record for a single parameter.
Assuming that the goal is to find some siblings, a proper record has to be added to program. It indicates what is the goal name (predicate name) and its arity. Furthermore, a many-to-many relationship has to be created between program and clause. It indicates which clauses belong to which programs. It is provided by program-clause and it implements consists_of relationship (see Figure 8.1). The above relations and their description are given in Table 8.2.
The decomposition resembles catalog-driven approach present in the most of the relational systems. The relational systems store information about databases, tables, columns, etc., in system catalogs (Some systems call this the data dictionary). The catalogs appear to the user as tables like any other, but the RDBMS stores its internal bookkeeping in them. The decomposed logic program may be perceived as an extension of the regular system catalogs, which allows to store intensional knowledge. It is just a step forward comparing with the system catalog of todays RDBMS.
Igor Wojnicki 2005-11-07