The Virgilio software system is a general purpose exploration tool for large collections of complex structured data. It generates visualisations of the results of a query to a database by the help of virtual reality objects, embedded into predefined virtual reality scenarios. This document describes the design, specification, and implementation of the Metaphor Definition Tool. This component of the Virgilio software system has to identify the most suitable virtual worlds for representing the result of a query. This is achieved by considering the metaphor definition task as a general constraint satisfaction problem. The logical formalism adopted to describe interrelationships among the involved objects corresponds to that of the Prolog programming language, in order to take advantage from its built in backtracking strategy. This paper presents the overall Virgilio architecture, provides a brief introduction to the concept of metaphor and its use within the Virgilio environment, contains a description of the MDT as well as a description of the repositories, and explains how to integrate the MDT into the whole system. Two complex mapping examples are also introduced.