Other Configuration Options

Zim Server has many possible configurations. multi-user single-user  

Zim Integrated Server

Usually, the Database Agent process accesses a local Zim database (local refers to relationship to the server). The Database Agent process is started much like any version of Zim: it has its own working directory; it uses Zim directory files to look up object names used in client requests; it uses areas.zim and dirs.zim in the standard way; and so on.

While a Zim database is being accessed by one or more Database Agent processes, it can also be accessed directly from a local multi-user Zim application, such as from a full Zim system, a query runtime system, or a runtime system.

When the Database Agent process receives a request to access a specific table, that table name is looked up in Zim directories. If the table is defined to be managed by another server (e.g. Oracle or another Zim Integrated Server), the Database Agent process uses the appropriate Server Access Module (SAM). For example, a Zim application running on Windows could access a table being managed by Zim Integrated Server running on an IBM platform. That server, in turn, could detect that the table is, in fact, managed by another Zim Server on an HP platform, so the request would be passed to the HP one. The Zim Server there could detect that, in fact, the table is really managed by Oracle running on a Linux environment, and so the request would be passed (by means of an Oracle SAM running on the HP) to Linux. See the diagram below.

Example of Possible Server Configurations

Client

A client process can connect to one or more Zim Servers at the same time. However Zim Database Agent processes (which can be on different machines) do not provide support for distributed deadlock detection or distributed transaction commit. As a result, two clients can deadlock each other. In addition, if a transaction updates information across more than one server, failures at either server or in communications could result in the transaction not being completely committed.

Because of Zim’s multi-server capability, a Zim application can concurrently access a local Zim database (local to the application), zero or more Zim databases managed by Zim Integrated Server, and zero or more third party databases (such as Oracle, DB2/2, etc.).

Example of Other Client Configurations

Compiling Client-Server Application Programs

The “SET SQLCOMPILE” Command

Zim is designed to take advantage of many characteristics of a given SQL server. Many SQL servers provide compile time facilities to increase performance at runtime. A compile time option enables you to control when the database server does certain compilation functions such as statement parsing. If SQLCOMPILE is OFF, then these functions are performed at Zim’s runtime. If SQLCOMPILE is ON, these function are performed as Zim compiles the application, if possible. This option is set using the command:

SET SQLCOMPILE [ ON | OFF ]

The default setting for SQLCOMPILE is OFF.

In order to take advantage of these facilities, you must be connected to the SQL server at compile time. If this option is turned off, all work is done at run time and you do not have to be connected at compile time.

Different applications being compiled against the same SQL server database can have programs with the same name (i.e. “MAIN”). To avoid conflicts that can arise when compiling several applications against the same SQL server database, each application should be flagged with a unique identifier. The “config.zim” entry is

SQL DATABASE NAME xxx

where “xxx” is a three-character ID. Zim makes use of this ID when compiling. It should be noted that SQLCOMPILE can be turned on or off for a single statement if desired.

Block Fetching

A dynamic configuration setting called "block factor" can be used to tune performance. This factor is the number of records retrieved by Zim each time it fetches records from the database. The larger the number, the fewer times Zim has to query the database, and the more time it takes to retrieve a block. So, the number must be adjusted to an appropriate value and not one that is arbitrarily large.

Continue reading “Block Fetching”

Program Execution

Zim is capable of executing database commands in either of these three modes:

SQLMODESQL mode
SERVERMODEZim Integrated Server mode
ZIMMODEStandard Zim mode

The default mode of operation is SERVERMODE. For all database servers except Zim Integrated Server, SERVERMODE and SQLMODE behave identically. In SERVERMODE, a Zim client accessing tables on Zim Integrated Server sends Zim commands to the server instead of SQL commands which greatly improves performance. In SQLMODE, the ZIM client determines the optimal SQL syntax to send to the server by inspecting the values for “EntType” or “RelType” in the Object Dictionary for the tables specified in the command.

The mode in which Zim operates may be set by the command:

SET EXECUTEMODE [ SERVERMODE | SQLMODE | ZIMMODE ]

where SERVERMODE is the default setting. For example, if the command:

set executemode zimmode

were executed, then Zim would revert to executing standard Zim code. If the program had been compiled in SQLMODE, it would revert to interpreting the program source file but issue error and warning messages.

Zim generates SQL statements to access entity sets and relationships that are stored in relational databases. To execute these statements (i.e. your application), you must be connected to the relational database. In order to support “off-line” development Zim enables you to turn off SQL statement generation, in effect generating standard Zim code. Zim ignores “EntType” and “RelType” and considers everything to be under Zim’s control. This enables you to develop and maintain applications without connecting to the database. In fact, development can proceed independent of the particular database vendor.

Tracing SQL Commands

In order to access relational databases, Zim client-server generates SQL statements. You can see the statements generated by setting SQLTRACE on. Statements are generated when Zim statements containing references to SQL tables are parsed, compiled, or executed interpretively. Previewing the SQL statements generated provides an insight into the type or amount of work the database is going to be doing. This option is set using the command:

set sqltrace [on | off]

The default setting for SQLTRACE is OFF.

Connecting and Recompiling the Zim Application

The application is compiled using the “compilemode” option “sqlmode” and conversion to a Zim Client-Server application is complete.

If the application is to be developed for execution against a pre-existing SQL server database, then the Zim application should be compiled using the “compilemode” option “zimmode” to test the application for functionality and performance. Then the application can be compiled using the “compilemode” option “sqlmode”. If the application is being compiled in the default “sqlmode” with the sqlcompile setting “on”, then you must be connected to the SQL server.

Accessing Multiple Databases at Same Time

Zim enables you to connect to more than one remote database at the same time. This enables you to do join operations between different databases on different machines managed by different Zim database servers. No support for distributed concurrency control is available; updates which span multiple servers, though permitted, should be performed with care.

As seen in The Preparation of the Client Database, the object being accessed must have its definition of the fields EntType, RelType or DocType changed to reflect the remote database being accessed via “zimserv”. In other words, all objects with the definition “zimserv” will be accessed in this particular remote Zim database once connected to it because the CONNECT statement links a particular remote database located in the network to the server type “zimserv”. Therefore, a Zim Server connection can only access one remote database at a time. If it is needed to access objects from different remote databases, a set of CONNECT and DISCONNECT commands must be issued for each object located in different remote databases.

There are situations, however, where it is needed to access all objects at the same time from different databases. This can be done by creating more than one instance or aliases of a “zimserv” via the utility modstab. For example, “zimserv1”, “zimserv2” or “Abroad” can be aliases of “zimserv”.

Consequently, if objects have their corresponding fields EntType, RelType or DocType created with any of the above aliases and after the CONNECT, these objects will be available from the correct remote databases.

The following example illustrates this idea. If Customers is locally located (that is, Entype is equal to “zim”), Cities has an EntType equals to “zimserv1” and Orders has an EntType equals to “Abroad”, then the FIND statement will access all customers in the local database that live in cities from the first remote database and that purchased something as defined in the second database:

CONNECT TO “zimserv1” USING (… parameters to access remote database named “zimserv1″…)

CONNECT TO “abroad” USING (… parameters to access remote database named “abroad”…)

FIND Customers LiveIn Cities Issue Orders

DISCONNECT FROM “zimserv1”

DISCONNECT FROM “abroad”

Zim Database Connection Concept

Distinguishing Between Zim 9 Server and Zim Server Connectivity

Zim 9 Server

  • Client/Server Mode: Zim 9 Server operates in Client/Server mode where Zim Server acts as the server, and Zim or Zim Thin Client are the clients.
  • Automatic Connection: Clients run a Zim application that accesses data provided by the server. Parameters, including the database name, are provided at the start of a client session to establish an automatic connection to Zim 9 Server.
  • Database Interaction: All data references are directed to the specified database until the client ends its operation.

Zim Server Connectivity

  • Accessing Multiple Databases: Clients can access data from another database serviced by the current Zim Server or another Zim Server on a different machine.
  • Connection Process: The client connects to a second database, performs data processing, and disconnects, all while still connected to the original database.
  • Concurrent Connections: Multiple Zim Server Connectivities can be performed with third or fourth databases, either simultaneously or sequentially.

Example Workflow

  1. Start Execution: ZIM executable connects to the “Original” database.
  2. Connect to Second Database: Explicitly connect to “Second” database, process data, and disconnect.
  3. Concurrent Connections: Connect to “Second” and “Third” databases concurrently, process data, and disconnect.
  4. End Execution: Automatically disconnect from “Original” database.

Comments

  • Explicit Connection: Use the CONNECT command with parameters to identify and connect to the desired database.
  • Database Agent: Zim Server starts a ZIM Database Agent to handle client operations. One agent per connection.
  • Disconnect Command: Use the DISCONNECT command to end the interaction and terminate the agent.

Concurrent Connections

  • Alias Configuration: Define aliases in the “zimalias.zim” configuration file to manage concurrent connections and ensure Zim knows which objects are related to each connection.

Security Considerations

Because client and server are separate processes (and can even be on different machines) with Zim Server Connectivity, there are some new options for providing security, although the same basic mechanisms are used.

Using ZIM Security

Within Zim, security is provided through a combination of log in user names, passwords, and entity set, relationship, and field level permissions. The following is a summary.

  • Entity sets and relationships belong to the user who created them. They each have Read, Add, Change, and Delete permissions assigned for the owner, anyone in the same group as the owner, and anyone else. A user must have the necessary permissions to carry out any given operation. For example, an entity set might have Read, Add, Change, and Delete permissions assigned for the owner. The group might have Read, Add, and Change while everyone else might only have Read permission. This means the owner can do anything to this entity set. Members of the group cannot delete records. Anyone else can only read the entity set. For more information, see Object Permissions.
  • Individual fields can have either Read or Read/Write permissions for the owner, group, and everyone else. If a user does not have any permissions for a field, then the field appears as $NULL to that user.
  • User names are defined in the Object Dictionary in the Users entity set. The PASSWORD command is used to define passwords and the LOGIN command is used to LOGIN as a specific user. When Zim is started, you are automatically logged in as the user ZIM. By default, this user is defined as a “super user” who has universal permissions for everything. However, the definition of this user may be changed (by updating the contents of the Users entity set).

Zim Server uses the same facilities. When a Zim application connects to Zim Server, a Database Agent process is started to service requests from that application. The CONNECT command can contain a user name and password. If it does, a LOGIN is executed at the server. If a LOGIN is executed for a specific user, then all subsequent requests to the server are executed under that user. Thus any permissions that have been set up at the server are obeyed.

Permissions (which are set using the PERMISSIONS command) are set in the server database using a development version of Zim with that database on the server machine. Permissions cannot be set from a client Zim application.

Using Operating System Security Features

You can use operating system features to provide security as well. Many possibilities here exist here, but the following points provide some guidelines. Since the means of specifying operating system level security varies from one operating system to another, actual operating system commands are specified. Consult your system documentation for more details on setting file permissions.

  • From an operating system point of view, it is the Database Agent process that accesses the files that make up the server database. The Database Agent process operates as the user that started the Zim Server process (unless either the Zim Server process or the Database Agent process have the “set userid” attribute. See your operating system documentation for details). The user that the Database Agent process operates as is called its effective user id. This means that, if the Database Agent process receives a request to read from part of the database, its effective user id must have the necessary operating system permissions to read from the associated files. Similarly, if a request to update the database is received, the Database Agent process’ effective userid must be able to write to the associated files. In general, ensure that the Database Agent process’ effective user id has read and write capabilities for all database files as well as any directories in which the database exists.
  • The Database Agent process is started by the Zim Server process.  The Zim Server must have the necessary permissions to execute the Database Agent process. However, the Zim Server process does not access the database directly, so it does not require any permissions with respect to the database.

Given the above, here is one scenario of how security could be provided by using operating system facilities:

  • In some cases, it might be desirable to make sure that database files can be accessed only through Zim Integrated Server. This ensures that no one can read or update database files unless they are using the server. Therefore, no one can circumvent the security features that have been implemented in your application or that have been implemented at the server using Zim facilities (see above). To do this, a special system user could be created that
  • is used to start the Zim Server process (and becomes the effective user id for the Zim Server and Database Agent processes).
  • owns the database directory and all files in it and has read/write permissions for all the files and directories.
  • is independent of other users so that no other users are able to access the database

Object Permissions

Entity sets, relationships and fields have security permissions that control how they can be accessed. The permissions defined at the remote database are independent of permissions defined at the client. The following chart illustrates the valid relationships.

  • At the server, an entity set, Customers, is defined as well as two users, Bob and Carol. Carl can Read, Add, Change or Delete Customers, but Bob can only Read the entity set. Carol has Read/Write permissions for the Salary Field, while Bob has no permissions for this field.
  • Customers is also defined in the Zim application at the client end. Two users are defined at the client, Ted and Alice. Ted has permissions to Read Customers and Alice has permission to Read, Add, Change, or Delete. Ted and Alice have Read/Write permissions for Salary.

Client LOGIN user name

CONNECT user name

Client Operation

Result

TedBobADD Customers…Client-side permissions disallow this.
TedBobLIST Customers…Data is retrieved but Salary appears as $NULL because of server side permissions for Bob.
TedCarolADD Customers…Client-side permissions disallow this.
TedCarolLIST Customers…All data is retrieved.
AliceBobADD Customers…Operation fails on the server side because Bob cannot add to Customers.
AliceBobLIST Customers…Data is retrieved but Salary appears as $NULL because of server-side permissions for Bob.
AliceCarolADD Customers…The operation proceeds.
AliceCarolLIST Customers…The operation proceeds.

Read-only fields

Read-only fields are database fields defined by in a table on the database server. The value of a read-only field is always assigned by the server. Such fields are often identity fields or primary keys that serve to uniquely identify a particular row or record in the table. To create a read-only field, set the Required field to the value of RO or ROE. RO and ROE both designate read-only fields. ROE fields are exported by the Export SQL Definitions facility in the Development Center. RO fields are not exported. When a field is defined as read-only, Zim does not generate syntax that assigns a value to this field, even if the language syntax assigns a value or a value is assigned implicitly because a form field name matches the name of the read-only field.

For example, RO is often useful for pseudo-columns that already exist on the server such as “ROWID” in Oracle database tables. If you create a field in a Zim entityset that reside sin an Oracle database with the name ROWID, Oracle always supplies a value for the field. Making it a read-only field in Zim ensures that Zim does not assign a value to it.

Guidelines to Use Zim Server Connectivity

There are two different moments when dealing with Zim Server Connectivity:

1) The preparation of client database: this step is done only once and creates data definitions to allow the client database to “see” what is defined in the other Zim database and it is obligatory;

2) The preparation of remote database: the other database must know the existence of some objects referenced by the client. This step is optional;

3) The interaction with another Zim database: this the real activity that connects, interacts and disconnects with the other database.

The Preparation of the Client Database

The client database needs to know what is the information that is going to be “seen” from the foreign database, that is, which entity-sets, relationships and documents are going to be visible by the client application. In other words, the client database must define these objects in its data dictionary (as it would define any other object) as they were defined in the foreign database with a certain degree of variation. For instance, a field originally defined in the foreign database does not need to be defined in the client database (for safety reasons or because this particular field is not needed) or even the format of the fields can be a little bit different like define a CHAR in the foreign database and define a VARCHAR in the client database, provided that the differences are not conflicting.

It is a good practice, though, to define all objects in the client database as they are defined elsewhere. Normally, definitions at the client database are obtained by exporting the definitions from the original database. In this way, all definitions in both sides will always be the same.

To export and import definitions from one database to another, use the Export Wizard and Import Wizard from DC.

There is another information needed to be provided to the client database. If objects are all defined the same way (that is, local objects or remote objects), a distinction has to be made so that the client session knows where the information has to be handled. This is told by the EntType, RelType and DocType fields in the definition of entity sets, relationships and documents respectively. Normally, these fields contain the value “ZIM” which tells the client session that the corresponding object is local. If these fields contain “zimserv”, then the client session will deal with these objects as being remote objects located in the other database.

There are two ways of changing the fields EntType, RelType or DocType:

1) Using DC:

when editing the corresponding object, there is a field called “Table Type” for Entity Sets and Relationships or a field called “Document Type” for Documents. Select “zimserv” in these fiedls. In this way, the Data Dictionary definition of object is changed and the object itself is recreated. Programs referencing this object must be recompiled;

2) Using the command SET TABLETYPE:

This command changes the internal state of the fields but does not change the Data Dictionary definition nor recreates the object. Existent compiled programs must be recompiled. Since this command is very practical but does not properly document the actions taken, it is only recommended when testing or briefly executing particular procedures. For additional information, refer to SET TABLETYPE command.

The Preparation of the Remote Database

This step is only required if the client requests for interaction specify objects only known by the client database. For example:

FIND Customers WHERE Code = 12345

The remote database can normally execute this command because the objects Customers, Code and 12345 are all known by the remote database (we are assuming that the client database defined Customers with the EntType equals to “zimserv”) because Customers is an entity set, Code is a field of this entity set and 12345 is a constant.

However, the command:

FIND Customers WHERE Code = MyForm

cannot be executed by the remote database because MyForm is not known there (we are assuming that MyForm is a form defined only in the client database). In this way, the object MyForm must be imported from the client database in order to be known in the remote database.

To export and import definitions from one database to another, use the Export Wizard and Import Wizard from DC.

The Interaction Between Databases

Once the client and remote databases have been prepared, the client application can connect to the remote database, retrieve and/or update data located there and then disconnect from the remote database.

In essence:

1) Establish the connection between the client and remote databases via the command CONNECT, passing parameters that identify which database is the remote database and where this database is located (some other parameters can be provided like the user and password);

2) Issue normal ZIM commands to process the information needed. Internally, the client session proceeds this way:

a) the command is parsed in the client which determines that some objects belong to a remote database (EntType, for instance, provides this information);

b) in this case, the command syntax is sent to the remote database where is parsed and executed. Along with the command, are also sent values needed for form fields, variables, parameter to procedures, etc.;

c) all variables, forms, form fields and sets that were sent to the server in the previous step are returned to the Zim application with any updated values. Commands that generate output, such as LIST or REPORT, return their output to the Zim application that writes it to the current output document as if the command had been executed locally. System variables such as $setcount are updated in the Zim application to indicate the result of executing the command on the server.

3) Destroy the connection whenever is no longer needed via the command DISCONNECT. This step is optional because the connection is automatically destroyed whenever the client session is terminated.

When the command is parsed (as in item 2a), a special situation might happen when a Zim command references a mixture of local and remote objects as in the following example:

FIND Customers Issue Orders

where Customers is a remote entity set and Orders is a local entity set. In this case, the client session cannot send the statement as it is because Orders does not have data in the remote database but rather the client sends a sequence of SQL statements to retrieve values from Customers and then relate them to Orders. Efficiency, in this case, can be very compromised.

The Zim Database Agent Functionality

In many respects, the Zim Database Agent operates like any other client session as it reads a database dictionary, reads the same configuration options file, parses and executes commands, etc. There are some differences though:

. It is automatically spawned by Zim Server when a CONNECT statement is executed by the client session and cannot be started manually by a user;

. It is automatically killed by the DISCONNECT statement executed by the client session or upon the termination of the client session;

. Because it always runs in background, it does not process any user interface commands. Commands like FORM DISPLAY are ignored;

. Upon its initialization, it executes the SERVPROF file instead of the ZIMPROF file;

. Upon its termination, it executes the SERVBYE file instead of the ZIMBYE file;

Database Object Definitions

Certain rules apply to the definition of objects that are common to the client and the remote database:

  • If an entity set or relationship in an application belongs to a Zim directory other than ZIM, then it must belong to a directory with the same name on the remote database or make use of the Remote Naming Feature (below). Also, the corresponding Zim directory must be accessed when the Zim Database Agent starts (see SERVPROF);
  • A document, an entity set or relationships must have the same name on the remote database or make use of the Remote Naming Feature (below);
  • At the remote database, you can define entity sets, documents and relationships that have no corresponding definition at the client. For example, such objects might be defined for use by local Zim applications only.
  • Fields defined in the application must also exist in the corresponding object on the remote database; the names of entity set or relationship fields must be the same on the server or make use of the Remote Naming Feature (below). However, the order of fields and their types do not need to match (although, if different types are used, conversion errors might occur depending on the actual data values).

Remote Naming Feature

Normally, data dictionary definitions at the client side are the same as those at the remote database.

There are circumstances where names must be different in which case the definition at the client side can use the RemoteName or RemoteOwnerName. These two fields are defined in DC when the object is also defined and tell which name and Zim directory are the real names at the remote database.

For example, at the client side, an entity set is defined with the name MyCustomers belonging to Zim directory MyZimDir in order to access, at a remote database, an entity set called Customers defined in Zim directory called ZimDir. In this case, the definition of RemoteName or RemoteOwnerName at the client side must be:

EntName: “MyCustomers”

DirName: “MyZimDir”

RemoteName: “Customers”

RemoteOwnerName: “ZimDir”

pt_BRPortuguese