PostgreSQL objects hierarchy
Understanding the organization of PostgreSQL database logical objects helps with the understanding of object relations and interactions. PostgreSQL databases, roles, tablespaces, settings, and template languages have the same level of hierarchy, as shown in the following diagram:

All objects in the hierarchy are explained in detail as follows.
Template databases
By default, when a database is created, it is cloned from a template database called template1
. The template database contains a set of tables, views, and functions, which is used to model the relation between the user-defined database objects. These tables, views, and functions are a part of the system catalog schema called pg_catalog
.
Note
The schema is very close to the namespace concept in object-oriented languages. It is often used to organize the database objects, functionality, security access, or to eliminate name collision.
The PostgreSQL server has two template databases:
template1
: The default database...