Skip to content

What is CoraDB?

View as Markdown

CoraDB is a hybrid relational and graph database management system. In one database it stores ordinary tables, queried with standard SQL, and vertex and edge tables that form property graphs, queried with SELECT … MATCH patterns — and a single query can combine both. CoraDB also offers object-relational features such as collections, JSON and table inheritance.

This page describes the architecture of CoraDB — its processes and database files — and its main features.

A CoraDB system consists of the database server, the broker, the CoraDB Manager Server (CMS) and, optionally, the Java SP server.

  • As the core component of the CoraDB database management system, the database server stores and manages data in multi-threaded client/server architecture. The database server processes the queries requested by users and manages objects in the database. The CoraDB database server provides seamless transactions using locking and logging methods even when multiple users use the database at once. It also supports database backup and restore for the operation.
  • The broker is a CoraDB-specific middleware that relays the communication between the database server and external applications. It provides functions including connection pooling, monitoring, and log tracing and analysis.
  • CMS lets administration clients manage databases and brokers remotely, with its own users and permissions.
  • The CoraDB Java SP server is an execution server that processes Java stored procedures/functions requested from the database server.

CoraDB process structure: the drivers (JDBC, PHP, ADO.NET, Python, Node.js, CCI) connect to the broker (job queuing, connection pooling, monitoring, logging, query parser and optimizer, lock cache), which works with the database server (query, lock, object, transaction, storage and log managers) over the database volumes (file-based objects, data and temp volumes, active and archive logs); beside them run CoraDB Manager Server (CMS), the Java SP server and the coradb utility

The following diagram illustrates the CoraDB database volume structure. As you can see, the database is divided into three volumes: permanent, temporary and backup. This chapter will examine each volume and its characteristics.

CoraDB database volume structure: the permanent volume holds the control file, data volumes, the active and archive logs and a temp volume, which works together with the temporary volumes; backup volumes hold the backups

For commands to create, add or delete the database volume, see createdb, addvoldb and deletedb.

Data volumes

Permanent data volumes are database volumes that exists permanently once they are created.

It usually stores data that needs to be persistent after database restart or crash. The possible types of permanent data are:

  • Tables (rows and multimedia data) are internally stored into heap files and heap overflow files, one file for each table.
  • Indexes (keys and multimedia data) are internally stored into b-tree files and b-tree overflow files, one file for each index.
  • System data is internally stored into several types of files: file tracker, vacuum data, dropped files tracker, and class names hash.

User can specifically assign some permanent data volumes to store temporary data. These volumes are permanent in the sense that they are never destroyed, but behave similarly to Temporary volume.

Control file

The control file contains the volume, backup and log information in the database.

  • Volume information: The information that includes names, locations and internal volume identifiers of all the volumes in the database. When the database restarts, the CoraDB reads the volume information control file. It records a new entry to that file when a new database volume is added.
  • Backup information: Locations of all the backups for data, index, and generic volumes are recorded to a backup information control file. This control file is maintained where the log files are managed.
  • Log information: This information contains names of all active and archive logs. With the log information control file, you can verify the archive log information. The log information control file is created and managed at the same location as the log files.

Control files include the information about locations of database volumes, backups and logs. Since these files will be read when the database restarts, users must not modify them arbitrarily.

Active log

Active log is a log that contains recent changes to the database. If a problem occurs, you can use active and archive logs to restore the database completely up to the point of the last commit before the occurrence of the fault.

Archive log

Archive log is a volume to store logs continuously created after exhausting available active log space that contains recent changes. If the value of system parameter log_max_archives is larger than 0, the archive log volume will be generated only after exhausting available active log volume space. The initial value is set to 0 when installing CoraDB. The number of archive log files is kept on the storage by setting the value of log_max_archives. The unnecessary archive log files should be deleted for getting the free space by the configuration of log_max_archives, but this value should be set properly to use for restoring the database.

To get more information on the above, see Managing archive logs.

Background archive log

Background archive log is a volume used in the background with log archiving temporarily before creating archive logs. It is created as the same volume size as active log and stored.

Double write buffer file

Double write buffer file stores copies of data pages being flushed to disk as a protection against I/O errors. A detailed description of this file can be found in Database volume section.

TDE key file

TDE (Transparent Data Encryption) key file contains keys for database encryption. The keys in the file are managed using the TDE utility. For more information on this, see File-based master key management and TDE utility.

Temporary data volume has the opposite meaning to the permanent volume. That is, the temporary volume is a storage file created temporarily which gets destroyed when the server process terminates. These volumes are used to store intermediate and final results of query processing and sorting.

These files provide space to store intermediary and final results of queries. Based on the size of required temporary data, it will be first stored in memory (the space size is determined by the system parameter temp_file_memory_size_in_pages specified in coradb.conf). Exceeding data has to be stored on disk.

Database will usually create and use temporary volumes to allocate disk space for temporary data. They user may however assign permanent database volumes with the purpose of storing temporary data using by running coradb addvoldb -p temp command. If such volumes exist, they will have priority over temporary volumes when disk space is allocated for temporary data.

The examples of queries that can use temporary data are as follows:

  • Queries creating the resultset like SELECT
  • Queries including GROUP BY or ORDER BY
  • Queries including a subquery
  • Queries executing sort-merge join
  • Queries including the CREATE INDEX statement

To have complete control on the disk space used for temporary data and to prevent it from consuming all system disk space, our recommendation is to:

  • Create permanent database volumes in advance to secure the required space for temporary data
  • Limit the size of the space used in the temporary volumes when a queries are executed by setting temp_file_max_size_in_pages parameter in coradb.conf (there is no limit by default).

Once temporary temp volume is created, it is maintained until a database restarts and its size cannot be reduced. It is recommended to make temporary temp volume automatically delete by restarting a database if its size is too big.

  • File name of the temporary volumes: The file name format of a temporary volume is db_name**_t**num, where db_name is the database name and num is the volume identifier. The volume identifier is decremented by 1 from 32766.
  • Configuring the temporary volume size: The number of temporary volumes to be created is determined by the system depending on the space size needed for processing transactions. However, users can limit the total temporary volume size by configuring the temp_file_max_size_in_pages parameter value in the system parameter configuration file (coradb.conf). The default value is -1, which means it can be created as long as free space is available. If the temp_file_max_size_in_pages parameter value is configured to 0, no temporary volumes will be created, and the system will have to rely exclusively on permanent volumes assigned for temporary data.
  • Configuring storing location of temporary volumes: By default, temporary volumes are created where the first database volume was created. However, you can specify a different directory to store temporary volumes by configuring the temp_volume_path parameter value.
  • Deleting temporary volumes: Temporary volumes exist only while the database is running. Therefore, you must not delete the temporary volumes when running servers. They are deleted when database servers are normally terminated. When database servers are abnormally terminated, temporary volumes are deleted on servers restart.

Backup volume is a database snapshot; based on such backup and log volumes, you can restore transactions to a certain point of time.

You can use the coradb backupdb utility to copy all the data needed for database restore, or configure the backup_volume_max_size_bytes parameter value in the database configuration file (coradb.conf) to adjust the backup volume partitioning size.

Database server process

Each database has a single server process. The server process is the core component of the CoraDB database server, and handles a user's requests by directly accessing database and log files. The client process connects to the server process via TCP/IP communication. Each server process creates threads to handle requests by multiple client processes. System parameters can be configured for each database, that is, for each server process. The server process can connect to as many client processes as specified by the max_clients parameter value.

Master process

The master process is a broker process that allows the client process to connect to and communicate with the server process. One master process runs for each host. (To be exact, one master process exists for each connection port number specified in the coradb.conf system parameter file.) While the master process listens on the TCP/IP port specified, the client process connects to the master process through that port. The master process changes a socket to server port so that the server process can handle connection.

Execution mode

All CoraDB programs except the server process have two modes: client/server mode and standalone mode.

  • In client/server mode, applications access server processes by operating themselves as client processes.
  • In standalone mode, applications include functionalities of server processes so that the applications can access database files by themselves.

For example, database creation and restore utilities run in standalone mode so they can use the database exclusively by denying the access by multiple users. Another example is that the corasql interpreter can either connect to the server process in client/server mode or execute SQL statements by accessing the database in standalone mode. Note that one database cannot be accessed simultaneously by server processes and standalone programs.

The broker is a middleware that allows various application clients to connect to the database server. The CoraDB system, which includes the broker, has multi-layered architecture consisting of application clients, cora_broker, cora_cas, and cora_server (database server).

Application client

Application clients connect through the CoraDB drivers: JDBC, Node.js, PHP, ADO.NET, Python and CCI (the C API).

cora_cas

cora_cas (CoraDB Common Application Server and broker application server (CAS in short)) acts as a common application server used by all the application clients that request connections. cora_cas also acts as the database server's client and provides the connection to the database server upon the client's request. The number of cora_cas(s) running in the service pool can be specified in the coradb_broker.conf file, and this number is dynamically adjusted by cora_broker.

cora_cas is a program linked to the CoraDB database server's client library and functions as a client module in the database server process (cora_server). In the client module, tasks such as query parsing, optimization, execution plan creation are performed.

cora_broker

cora_broker relays the connection between the application client and the cora_cas. That is, when an application client requests access, the cora_broker checks the status of the cora_cas through the shared memory, and then delivers the request to an accessible cora_cas . It then returns the processing results of the request from the cora_cas to the application client.

The cora_broker also manages the server load by adjusting the number of cora_cas (s) in the service pool and monitors and manages the status of the cora_cas. If the cora_broker delivers the request to cora_cas but the connection to cora_cas 1 fails because of an abnormal termination, it sends an error message about the connection failure to the application client and restarts cora_cas 1. Restarted cora_cas 1 is now in a normal stand-by mode, and will be reconnected by a new request from a new application client.

Shared memory

The status information of the cora_cas is stored in the shared memory, and the cora_broker refers to this information to relay the connection to the application client. With the status information stored in the shared memory, the system manager can identify which task the cora_cas is currently performing or which application client's request is currently being processed.

CoraDB provides these drivers:

All drivers access the database server through the broker, which runs the statements on their behalf in a CAS process.

Hybrid relational and graph model

Vertex tables hold the nodes of a graph and edge tables the relationships between them; both are tables with typed columns (properties), indexes and SQL access. SELECT … MATCH queries find paths and patterns, such as customers who like products of a given brand, and can be joined with relational tables in the same statement. See Relational and graph in one query, the tutorial and the MATCH clause.

Transaction support

CoraDB supports the following features to completely ensure the atomicity, consistency, isolation and durability in transactions.

  • Supporting commit, rollback, savepoint per transaction
  • Ensuring transaction consistency in the event of system or database failure
  • Supporting multiple granularity locking of databases, tables and records
  • Resolving deadlocks automatically

Database backup and restore

A database backup is the process of copying CoraDB database volumes, control files and log files; a database restore is the process of restoring the database to a certain point in time using backup files, active logs and archive logs copied by the backup process. For a restore, there must be the same operating system and the same version of CoraDB installed as in the backup environment. The backup methods which CoraDB supports include online, offline and incremental backups; the restore methods include restore using incremental backups as well as partial and full restore.

Table partitioning

Partitioning is a method by which a table is divided into multiple independent logical units. Each logical unit is called a partition, and each partition is divided into a different physical space. This will lead performance improvement by only allowing access to the partition when retrieving records. CoraDB provides three partitioning methods:

  • Range partitioning: Divides a table based on the range of a column value
  • Hash partitioning: Divides a table based on the hash value of a column
  • List partitioning: Divides a table based on the column value list

Supports a variety of index functions

CoraDB supports the following index functions to utilize indexes while executing a variety of conditional queries.

  • Descending Index Scan: Descending Index Scan is available only with Ascending Index Scan, without creating separate descending indexes.
  • Covering Index: When the column of a SELECT list is included in the index, the requested data can be obtained with an index scan.
  • ORDER BY clause optimization: If the required record sorting order is identical to the order of indexes, no additional sorting is required (Skip ORDER BY).
  • GROUP BY clause optimization: If all columns in the GROUP BY clause are included in the indexes, they are available to use while executing queries. Therefore, no additional sorting is required (Skip GROUP BY).

Java stored procedure

A stored procedure is a method to decrease the complexity of applications and to improve the reusability, security and performance through the separation of database logic and middleware logic. A stored procedure is written in Java (generic language), and provides Java stored procedures running on the Java Virtual Machine (JVM). To execute Java stored procedures in CoraDB, the following steps should be performed:

  • Install and configure the Java Virtual Machine
  • Create Java source files
  • Compile the files and load Java resources
  • Publish the loaded Java classes so they can be called from the database
  • Run CoraDB Java SP server for the database (see CoraDB Java stored procedure server)
  • Call the Java stored procedures

Click counter

In the Internet environment, it is common to store and keep counting information like page view in the database to track search history.

The above scenario is generally implemented by using the SELECT and UPDATE statements; SELECT retrieves the data and UPDATE increases the number of clicks for the retrieved queries.

This approach can cause significant performance degradation due to increased lock contention for UPDATE when a number of SELECT statements are executed against the same data.

To address this issue, CoraDB introduces the new concept of the Click Counter that will support optimized features in the Web in terms of usability and performance, and provides the INCR function and the WITH INCREMENT FOR statement.

Extending the relational data model

  • Collection

    For the relational data model, it is not allowed that a single column has multiple values. In CoraDB, however, you can create a column with several values. For this purpose, collection data types are provided in CoraDB. The collection data type is mainly divided into SET, MULTISET and LIST; the types are distinguished by duplicated availability and order.

    • SET: A collection type that does not allow the duplication of elements. Elements are stored without duplication after being sorted regardless of their order of entry.
    • MULTISET: A collection type that allows the duplication of elements. The order of entry is not considered.
    • LIST: A collection type that allows the duplication of elements. Unlike with SET and MULTISET, the order of entry is maintained.
  • JSON

    JavaScript Object Notation (JSON) has become the de facto standard for data-interchanging. JSON, one of the semi-structured data, is not allowed to reside in the relational data model. In CoraDB, however, you can create and query JSON documents using SQL functions for JSON. you can define a JSON data type column and stores a JSON document into the column.

  • Inheritance

    Inheritance is a concept to reuse columns and methods of a super class (table) in those of a sub class. CoraDB supports reusability through inheritance. By using inheritance provided by CoraDB, you can create a super class with some common columns and then create a sub class inherited from the super class with some unique columns added. In this way, you can create a database model which can minimize the number of columns.