Skip to content

Preparing the database#

Before creating a connection, whoever administers the client database must prepare a user for Empowerment Center, a work schema and the permissions. This page says what ECenter needs in each engine and why.

Before you start#

  • You need the help of whoever administers the client database: permissions are granted in the engine, not in ECenter.
  • ECenter 8.0 works with PostgreSQL, SQL Server and Oracle, with their JDBC driver. The file databases that EC7 supported are not accepted as a connection; Access and DBF files can be brought in as external data.

What ECenter does in the client database#

Where What it does Permissions it needs
Data schemas Reads the tables and views being analyzed and their structure (columns, primary and foreign keys, indexes). Read (SELECT) on the tables and views, and see their definition in the engine's dictionary.
Data schemas, only if forms are used Inserts, changes and deletes records of the tables edited in forms. INSERT, UPDATE and DELETE on those tables, and use of the sequences named by the next-value SQL.
Work schema Creates, loads, empties and drops its own tables: those of lists (ECW_LIST_…), groupings (ECW_GRP_…), the values of a query with many values (ECW_VAL_…) and external data (ECX_…). Create and drop tables and indexes, insert, update, delete and lock rows in them.
Stored procedures, only if they are scheduled The scheduler runs them with their arguments. EXECUTE on each procedure.

Note

ECenter never changes the structure of the tables in the data schemas. Everything it creates goes to the work schema, which must be different from the data ones.

The connection user#

Create a user of its own for ECenter, with a password nobody else uses. It is the one entered in the connection dialog and the one that opens all the sessions with the database: those of cubes, lists, forms, the catalog and scheduling.

The simplest way, in all three engines, is for that user to be the owner of the work schema and to have read access to the data schemas.

Important

Do not use a superuser or a database administrator (postgres, sa, SYSTEM…). The metadata administrator writes SQL fragments (expressions, dimension functions and universes) that run with this user: with one like that, they could read files or run programs on the database server.

An indicative example, with the demo schemas (COMERCIAL for data and ECW for work); adapt it to your standards:

CREATE ROLE ecenter LOGIN PASSWORD 'change-this-key';
-- The work schema, owned by the ECenter user
CREATE SCHEMA "ECW" AUTHORIZATION ecenter;
-- Read access to the data
GRANT USAGE ON SCHEMA "COMERCIAL" TO ecenter;
GRANT SELECT ON ALL TABLES IN SCHEMA "COMERCIAL" TO ecenter;
ALTER DEFAULT PRIVILEGES IN SCHEMA "COMERCIAL" GRANT SELECT ON TABLES TO ecenter;

In PostgreSQL a name created without quotes is stored in lower case (ecw); with quotes, as written ("ECW").

An indicative example; adapt it to your standards:

CREATE LOGIN ecenter WITH PASSWORD = 'change-this-key';
USE comercial;
CREATE USER ecenter FOR LOGIN ecenter;
-- The work schema, owned by the ECenter user, and permission to create tables in the database
CREATE SCHEMA ECW AUTHORIZATION ecenter;
GRANT CREATE TABLE TO ecenter;
-- Read access to the data
GRANT SELECT ON SCHEMA::COMERCIAL TO ecenter;
GRANT VIEW DEFINITION ON SCHEMA::COMERCIAL TO ecenter;

In Oracle a schema is a user. The simplest way is to connect as the owner of the work schema, with read access to the data tables:

CREATE USER ECW IDENTIFIED BY "change-this-key" QUOTA UNLIMITED ON USERS;
GRANT CREATE SESSION, CREATE TABLE TO ECW;
-- Read access to each data table or view (or a role with them)
GRANT SELECT ON COMERCIAL.FACTURAS TO ECW;

If the connection user is not the owner of the work schema, it also needs CREATE ANY TABLE, CREATE ANY INDEX, DROP ANY TABLE, LOCK ANY TABLE, SELECT ANY TABLE, INSERT ANY TABLE, UPDATE ANY TABLE and DELETE ANY TABLE.

This second way is not valid if ECenter's own database is in that same database: with SELECT ANY TABLE, the connection user also sees the ECenter schema. There, connect as the owner of the work schema and give it the data with GRANT SELECT table by table or through a role (see The connection user and the own database).

In Oracle a name created without quotes is stored in upper case (ECW).

The connection user and the own database#

The user of a connection cannot see ECenter's own database. Whoever administers the metadata and the workbooks writes SQL that runs with that user: SQL lists, metadata expressions, scheduled procedures. If that user could read the ECenter tables, that SQL would reach the users, the encrypted credentials and the audit.

With the own database in a separate PostgreSQL, a connection's user does not reach it. When the own database is in the same database as the data (a schema of the organization's Oracle, see The own database in Oracle), it depends on the permissions, and ECenter watches it in three places:

When What ECenter does
When saving a connection, or testing the one about to be saved, with the own database's account (the same user in the same Oracle database) It rejects it without opening a session, with the error below User. It does not ask whether to save anyway: that connection is not saved.
When you Test any connection It asks, with the connection's session, whether its user sees any ECenter table. If it does, the test fails with “The connection works, but its user is not valid:”.
In each check of the connections, every 5 minutes If the user of an active connection sees the own database, it opens the critical alert A connection sees the own DB, one per connection, which resolves itself when it stops seeing it (see Operational alerts).

The messages do not name the user, the database or the tables it sees. They are in Creating and testing a connection.

What “seeing” means. In Oracle, having any table of the ECenter schema within reach: through a permission on it, through a role or through SELECT ANY TABLE. With the own database in PostgreSQL the same is watched, when testing and with the alert, if a connection reaches the own database's database with another user that can read it: a superuser, for example.

How to connect in the same database#

  • The ECenter user and the connection user are two different users. The ECenter one only has the permissions of its schema.
  • The connection signs in with the owner of the work schema and receives the data with GRANT SELECT table by table or through a role.
  • No ANY or DBA privileges. The way of connecting with a user that does not own the work schema and has SELECT ANY TABLE and the other … ANY TABLE is not valid here.
  • Nobody gives the connection user permissions on the ECenter tables.

Fixing a connection that already sees it#

  1. Look at what has been granted on the ECenter tables and which ANY privileges the connection user, or one of its roles, has. An indicative example, with ECENTER as the ECenter schema:

    -- What has been granted on the ECenter tables
    SELECT grantee, table_name, privilege FROM dba_tab_privs WHERE owner = 'ECENTER';
    -- The ANY privileges
    SELECT grantee, privilege FROM dba_sys_privs WHERE privilege LIKE '% ANY %';
    
  2. Remove them with REVOKE, or change the connection user for one that does not have them (see Maintaining a connection).

  3. Press Test on the connection. When the test passes, the alert resolves itself at the next check; to avoid waiting, press Check now in Administration › Operations › Alerts.

Important

With the own database in PostgreSQL, ECenter does not reject a connection that signs in to that same database with the ECenter user. Do not create it: the own database user is for ECenter only.

The work schema#

  • If you cannot give ECenter a schema to write in, create the connection as read-only: a user that reads the data schemas is enough, in exchange for not having lists, groupings, external data, forms that save or procedures (see A read-only connection).
  • It must exist before the connection is created: ECenter does not create it.
  • Type its name exactly as the engine stores it, with its upper and lower case. ECenter uses it as it is and in quotes. If it only matches case-insensitively, Test does not accept it and says what it is called: «El esquema de trabajo se llama «ecw» en la base de datos, no «ECW»: escríbalo así, con esas mayúsculas, porque ECenter lo usa tal cual» (the work schema is called “ecw” in the database, not “ECW”: type it like that, with that case, because ECenter uses it as it is).
  • Data schemas, on the other hand, are found case-insensitively.
  • Several connections of the same installation to the same database can use the same work schema; the two demo ones use ECW. The names of their tables carry the identifier of each list, grouping or load, which is unique in the installation. Two ECenter installations (production and test, for example) must not share a work schema: their identifiers would coincide.
  • Do not use it for other things: the catalog does not read it as a data schema, except to recognize the external data tables.

Quoting the names#

The Quote table and column names option decides how ECenter writes the names in the SQL:

With the option ticked Not ticked
Each schema, table and column goes in quotes ("COMERCIAL"."CLIENTES"."COD_ZONA", or in square brackets in SQL Server), with the exact name the catalog gives. Names go without quotes, and the engine converts them to its form (upper case in Oracle, lower case in PostgreSQL).
It accepts names in lower case, with spaces or with letters such as Ñ (OBJETIVOS."AÑO" in the demo). It only accepts plain identifiers: a letter or _ followed by letters, digits, _ or $ (and # in Oracle and SQL Server). A name with another character gives an error when querying (it cannot be written without quotes).

A new connection comes with it ticked. Leave it ticked unless you have a reason to clear it: with it, ECenter writes the names as it sees them in the catalog and does not depend on how each engine converts them.

Important

Changing this option on a connection with metadata changes all the SQL that is generated. Do it before designing the metadata, or test the documents afterwards with Validate content (see Usage and validation).

Check that everything is fine#

The Test button of the connection dialog does with the details entered, without saving anything, the same as ECenter needs afterwards:

  1. It opens a session with the user and the password.
  2. It checks that the data schemas and the work schema exist.
  3. It creates a table in the work schema (ECW_PROBE_…) and drops it.
  4. It checks that its user does not see ECenter's own database, if it is in that same database.

In a read-only connection there is no work schema: Test skips steps 2 (the work schema) and 3, and creates nothing.

If something fails, it says which step and the reason the database gives. See Creating and testing a connection.

See also#