Large collections of documents are commonly created around a database, where a typical database schema may contain hundreds of tables and thousands of columns. We developed a system based on SQL code generation and User-Defined Functions that analyzes document-to-metadata links by extracting a basic set of relationships at different levels of granularities: coarse, medium and fine. Such relationships are then stored and queried in the DBMS, allowing the user to explore, query, and rank how columns and tables are related to users and applications. At the same time, our system provides typical information retrieval capabilities for querying medium-sized document collections of interrelated documents in the DBMS, with an acceptable performance. Categories and Subject Descriptors H.2.7 [Database Management]: Database Administration--Data warehouse and repository General Terms Management, Documentation, Design