Associating data assets to a schema

Once a schema has been created to act as a container for the data assets, each dataset can be associated with one or more schemas in the database by using standard SQL ALTER TABLE syntax.

The following example adds dataset1, dataset2, dataset3 and v1 to the databaseA.schema1 container created in the previous example.

ALTER TABLE dataset1 ADD SCHEMA databaseA.schema1;

ALTER TABLE dataset2 ADD SCHEMA databaseA.schema1;

ALTER TABLE dataset3 ADD SCHEMA databaseA.schema1;

ALTER VIEW v1  ADD SCHEMA databaseA.schema1;

Accessing data assets from the data container

By appropriately qualifying the database name, any PostgreSQL client can connect to any of the data structures you have created using the SHOW keyword. For more information on the SHOW keyword please see the SHOW section within the SQL syntax documentation.

“all” is the default database name that contains every database and schema container in a sandbox. When you make a PostgreSQL connection using dbname="all", you can access any database and schema that you have created to logically organize your data.

Listing all databases under dbname="all" displays three available databases.

SHOW DATABASES;

name
---------
databaseA
databaseB
databaseC

Listing all schema under dbname="all" displays the three schemas related to every database in the sandbox.

SHOW SCHEMAS;

database       | schema
----------------------
databaseA      | schema1
databaseA      | schema2
databaseB      | schema3

When you make a PostgreSQL connection using dbname="databaseA", you can access any schema associated with that specific database, as shown in the example below.

SHOW DATABASES;

name
---------
databaseA


SHOW SCHEMAS;

database       | schema
----------------------
databaseA      | schema1
databaseA      | schema2

Dot notation allows you to access every table associated with a specific schema connected to your chosen database. By connecting to DBNAME = databaseA.schema1;, all tables associated with that specific schema (schema1) are shown. This provides information on which dataset contains which table.

SHOW DATABASES;

name
---------
databaseA


SHOW SCHEMAS;

database       | schema
----------------------
databaseA      | schema1


SHOW tables;
name       | type
----------------------
dataset1| table
dataset2| table
dataset3| table