For Programmers: Free Programming Magazines  


Home > Archive > Prolog > April 2004 > Working on different databases









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Working on different databases
Maciek

2004-04-22, 9:38 pm

My situation is like that: I work on one, let's say basic database.
There are most important facts in there. But sometimes, when I have no
solution I want to support by the "less important" facts. My idea is
to place them in diffrent database and use only if there is no other
way of achieving the goal. What you think? Is it any elegant way of
doing that, or maybe there is another, better solution?
Asserting and retracting is not a way of doing that I think, as there
are too many of these facts and they're not result from any rules.
Besides that, after using a fact from the "supporting" database I'd
like to take into account the "basic" one only in the next subgoal
unless I can't find any solutions.
I hope it's clear, if not or it's totally wrong question - forgive me
I'm not too experienced in that problem.
Thanx in advance,
Maciek
Benjamin Johnston

2004-04-23, 11:32 pm


I'm not entirely sure about what you're trying to do ---

But, maybe what you could do is have an extra argument on each declaration:

parent(joe, fred, supporting).
parent(peter,joe, _).
parent(david, fred, supporting).
parent(rob,david, _).

grandparent(A,C,Mode) :-
parent(A,B,Mode),
parent(B,C,Mode).

So if you want to use the basic database:
grandparent(peter, fred, basic)

and if you wanted to use the full database:
grandparent(peter, fred, supporting).

Because the basic facts have free variables in the mode, then they'll unify
to supporting and basic... but the supporting facts will only unify with the
"supporting" mode.

-Benjamin Johnston

> My situation is like that: I work on one, let's say basic database.
> There are most important facts in there. But sometimes, when I have no
> solution I want to support by the "less important" facts. My idea is
> to place them in diffrent database and use only if there is no other
> way of achieving the goal. What you think? Is it any elegant way of
> doing that, or maybe there is another, better solution?
> Asserting and retracting is not a way of doing that I think, as there
> are too many of these facts and they're not result from any rules.
> Besides that, after using a fact from the "supporting" database I'd
> like to take into account the "basic" one only in the next subgoal
> unless I can't find any solutions.
> I hope it's clear, if not or it's totally wrong question - forgive me
> I'm not too experienced in that problem.
> Thanx in advance,
> Maciek



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com