Theory in practice: Why Treating Metadata as Relations Pays Off by Eduardo Bellani

Underpinning relational databases you find a very powerful principle: all your information should be represented as attributes drawn from domains in relations(Pascal 2020). This is Codd’s Information Principle #1. This principle isn’t just fluffy theory: it can lead to very concrete wins in how we design, query, and maintain systems.1

A practical case: Dependencies for Security Policies

This is clearly a metadata question: Which other database objects does this view depend on? In many environments, answering that might involve using external tools or writing scripts in another language. But in PostgreSQL, you can answer it with a simple query because PostgreSQL respects Codd’s principle and exposes metadata as part of its relational structure.

select distinct
  source_schema.nspname as source_object_schema_name,
  source_object.relname as source_object_name,
  dependent_schema.nspname as dependent_object_schema_name,
  dependent.relname as dependent_object_name,
  dependent.relkind as dependent_object_type
  from
    pg_rewrite rw
    join pg_class     source_object      on rw.ev_class    = source_object.oid
    join pg_depend    dep              on dep.objid      = rw.oid
    join pg_class     dependent        on dep.refobjid   = dependent.oid
    join pg_namespace source_schema    on source_schema.oid = source_object.relnamespace
    join pg_namespace dependent_schema on dependent_schema.oid = dependent.relnamespace
 where
     (dependent_schema.nspname <> source_schema.nspname or dependent.relname <> source_object.relname)
     and source_object.relname = 'MY_VIEW' and source_schema.nspname = 'MY_SCHEMA';
Code Snippet 1: Retrieves all objects (tables, views, etc.) that MY_SCHEMA.MY_VIEW depends on — across schemas and object types

Conclusion

When your system represents metadata relationally, you can reason about it with the same tools you use for business data. No context-switching, no ETL jobs, no external tools. Just your relationally inspired SQL.

This aligns with the foundational ideas behind relational databases and shows that following sound principles can yield practical advantages.

References

Pascal, Fabian. 2020. “Understanding Codd’s 12 Rules for Rdbms (Accessed on 2025-04-14).” https://www.dbdebunk.com/2020/10/understanding-codds-12-rules-for-rdbms.html.
Figure 1: The Cathedral of the Archangel Michael in Bronnitsy underwent a relatively mild transformation: It was used as a state book archive - but the “book of books,” the Bible, surely couldn’t be found there.

Figure 1: The Cathedral of the Archangel Michael in Bronnitsy underwent a relatively mild transformation: It was used as a state book archive - but the “book of books,” the Bible, surely couldn’t be found there.


  1. Recently I had a conversation on linkedin: https://www.linkedin.com/feed/update/urn:li:ugcPost:7316402764975075328?commentUrn=urn%3Ali%3Acomment%3A%28ugcPost%3A7316402764975075328%2C7316457084038930432%29&dashCommentUrn=urn%3Ali%3Afsd_comment%3A%287316457084038930432%2Curn%3Ali%3AugcPost%3A7316402764975075328%29 ↩︎