Query / Goal: A question posed to the engine, e.g. ?- grandparent(alice, W). The engine searches for a W that satisfies the rules. In logic programming, a query or goal is a question you ask the system. In Prolog, ?- grandparent(alice, W). asks: for which W is Alice a grandparent? The engine searches through its facts and rules, trying combinations and backtracking when one fails, until it finds values that make the goal true. It can return one answer or all of them.
The nice part is that the same rules answer different questions. The rule defining grandparents also answers "who are Bob's grandparents?" without writing new code. SQL works in a similar declarative spirit: you describe the result, and the database finds it. Thinking in goals rather than steps is useful whenever a problem is mostly about relationships and rules.
Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.