Here I propose the SQL script creating the DB structure for the user's catalogues. To properly understand the idea, the reader should understand the overall DB stucture in CAS ( see CASDB ).

So, the main purpose of the structure described below is to preserve the already existing interfaces of retrieving the metadata about the catalogues, and to make the interfaces almost independ on the fact whether the queries are run from the anonymous user (when only CAS main tables are seen) or from some specific user with his own set of tables.

The scripts for creating of the user's DB structure are available here And the set of functions:

So after that setup, if the user "someuser" will use the search_path=cas_metadata_someuser,cas_metadata in the tables (catalog_list, table_list, attribute_list) he will see the same his own data and the data from system tables. Also since the catalog_list, table_list and attribute_list are just VIEW's it is easy to include in those VIEWs the tables from the other login for example (if somebody wants to share his tables with another login).

That script seem to leave working all the interface functions from the CASDB

Another important notice, that as the primary key I'm using the SEQUENCEs from the ids of the system tables!!!, so the id numeration in the whole system will be consistent (I need that, since several my interface functions do the id lookup, and I don't want to break them on the VIEW like table_list which is union of the table_user_list and system table_list)