Skip to content

The Opera database technology

Introduction

The Opera database is a proprietary, file-based, ISAM-like relational database system, not a conventional client/server SQL database. It supports multiple users, data integrity and consistency.

Naming

  • table = archive

  • row = record

  • column = field

Storage

The data of every table is stored in files. files with the same name and different extension belong to the same archive. The files are named with a common prefix like OPERA and three letters to identify the table. In the Opera interface and documentation the table is referred with the word archive.

The table files are stored in directories. In the configuration of the Opera there is the UNC path of the directory containing the table files. If this UNC points to a shared folder on a server, multiple instances of Opera in different workstations can access the database concurrently. All users accessing the table files need to have R/W access to the files. Opera accepts UNC path style that should be preferred to network driver letter paths.

Database sharing

Opera instances can access concurrently the same tables using the operative system file sharing access methods.

It's a peer-to-peer system and Opera trust the OS in order to ensure consistent modifications and atomic file locking.

If an Opera instance wants to write on a table, it tries to lock a .LOCK file with the same name as the table filename. This is a lock at the table level.

  • If the lock succeeds, Opera writes in the .LOCK file who and why the table is locked, modify the rows data, increment the modification counter on the table to notify the other Opera instances to clear their cache and release the lock

  • If the file is locked, Opera waits until the locking polling ends and tries to lock the .LOCK file. If the file is still locked, after a couple of seconds Opera reads the .LOCK file to find when the file got locked and which Opera instance and user locked the table. Then this info is displayed in a warning window.

At row level, when a user enters in a record to modify the values a specific .LOCK file is created just for that row so that other users can modify other rows on the same tables, but they will be prevented to modify that row. A message with the name of the modifying user will appear, using the same mechanism explained above for the table locking level. Once the modification ends (with a save row or a cancel modification actions), the row .LOCK file is released and the other users will get access to modify that row again.

Opera users

When starting the Opera software you're prompted for login with a specific Opera user.

Opera keeps a table of users. Users in Opera have several attributes, ex. they can have the right or not to see or interact with certain data (ex. prices, a production operator has no need to see prices) or they can access in read-only mode to sensitive data (ex. an estimator cannot to modify the dimension of a profile which in turn in cascade will modify from the cutting list down to quantities and machine jobs).

Every user has a password. In order to add/modify users there is a general numeric password (called Permissions password) that is needed to modify the Users table. This password is independent from the Users rank or password. Knowing the Permission password lets any user to interact with the users table.

To Enter or modify the permission password in OperaJM, you need to go to Parameters → Passwords in the Main menu. The password is stored inside Opera's hardware USB dongle, so tampering with the database files doesn't affect the Users table access. It means also that if a company has multiple USB dongles they must setup the Permission password on every dongle because if there is no password in the dongle any user can setup a permission password.

If the Permission password is lost only Opera Company can create and issue a special code which resets the password on the USB dongle.

Upgrade of Opera to version 3.10.1 resets all passwords as the information stored on the USB dongle memory changed schema.

Table files

Table file extensions

  • .DAT contains the actual columns values.

  • .LOG is a text file containig the history of the table modifications with timestamp, user, action and a payload wih the modified data itsef compressed and base64 encoded to be able to rebuild the transactions data.

  • .IPKEY contains the list of each row primary key (always an integer).

  • .IO contains the offset of every row in case the table is a dynamic size record type.

  • .Ixx where xx is a number from 0 to n and represent the indexes used to perform binary search. The index file has a header which contains the modification index of the .DAT file. It doesn't match the index will be automatically rebuilt.

  • .MD5 contains the hashing of evey row in the table and is used to quickly compute if a row value has changed or not.

Example of a file collection in the systems table: OPERASIS.DAT OPERASIS.I0 OPERASIS.I1 OPERASIS.LOG OPERASIS.MD5

If the .I* or .MD5 files are missing or become inconsistent they are rebuilt on the fly with no error messages.

.DAT File map

Data is stored in the .DAT file in binary format. The .DAT file has a header with table information 1024 bytes long and then the rows content payload. The header contains name, description, row length, type of table (fix or dynamic row size), modification counter and an integer number signature that identifies the type of data (system, profile, accessory, color, price, etc. etc.) so that the application doesn't open a file which contains binary data inconsistent with the desired target. There are two types of tables

  1. fix row length

  2. dynamic row length

A fix length table contains the binary copy of a C language object directly used in the software. If this binary data is corrupted the software can crash (ex. a C language NULL terminated string is not terminated and longer than the expected or a IEEE 754 float value is a non valid number).

In dynamic length row tables, the data is structured with a record header containing the total length of the row data and the CRC of the hader itself to validate the header and rebuild corrupted files. Then the row header which contains the binary copy of the C language object and finally the variable size data. The variable size data is provided by a custom serialization function for each different type of data, the function is coded in the application. The dynamic table format has an option to compress the row content to limit the .DAT size.

Both fix and dynamic tables cannot be bigger than 2Gb as Opera is a 32bit application and won't use 64bit file cursors.

Directories

In OperaJM there is a database configuration mask. It is usually accessible through the main menu choosing Database->Directories. The mask contains several fields to specify the database directories. Usually, tables are organized in different directories for logical and support reasons and for certain directories containing common tables (like users and master data for clients and suppliers) in order to keep in the same directory to be pointed from different apps.

Example:

OperaJM shares with OperaAM the master data of clients and suppliers and sometimes users.

Application version vs database version

If the size of a C language object changes among Opera versions, during the opening phase of the table, the .DAT will be rebuilt to reflect the new size. For this reason the peer-to-peer access to the database must be only among identical versions of the application. To enforce this constraint in the .DAT table file header there is a specific section to save the Opera software version.

When OperaJM opens the database tables at the startup creates and lock and write a .LOCK file in the directory which contains the tables to notify the other OperaJM instances that he's using the database. The directory lock file name is FOLDERxx.OPEN* where xx is a incremental number to cope with the other directory lock files from other OperaJM instances. In this *.OPEN file OperaJM writes his own software version, the hostname and the Opera user.

If other .OPEN files exist in the directory and they are write locked, OperaJM make sure that the software version on this files is the same of his own. If not, it prompts an error message and abort the database open activity. This to avoid to Open a shared database with peers of a different software version.