I think you want to google "triple store" because that is effectively what you are trying to do AIUI. Triple stores are the persistence strategy of choice for RDF and other Semantic-Web-type applications.
Each row in a triple store stores a relationship between 2 objects, with unique IDs for the subject, the relationship type, and the object. The IDs could refer to other tables that store entity and relationship details.
There are specialised triple store DBMSs, but implementing one in PostgreSQL should be pretty easy.
Comments
I think you want to google "triple store" because that is effectively what you are trying to do AIUI. Triple stores are the persistence strategy of choice for RDF and other Semantic-Web-type applications.
Each row in a triple store stores a relationship between 2 objects, with unique IDs for the subject, the relationship type, and the object. The IDs could refer to other tables that store entity and relationship details.
There are specialised triple store DBMSs, but implementing one in PostgreSQL should be pretty easy.