Two basic directions of inference are theoretically possible: the forward chaining (or data-driven inference), and the backward chaining (or goal directed inference) [4].
The forward chaining works forward, starting from available knowledge. It assumes mentally, that the head of a rule is an action (or conclusion), and the body is the condition for performing this action. The inference engine does not have a goal in a form of query. Instead, it looks at all the facts stored in the database. If these facts satisfy the condition of some rule, the inference engine fires that rule by performing the action the rule specifies. So it starts from the facts and works towards consequences.
The backward chaining starts with a goal (query), then the body (or bodies) of the rules involved by the goal becomes a new goal etc. So the inference starts with a goal and works towards facts that prove the goal.