CUBRID: A FOSS RDBMS to Realise Your Next Big Idea
CUBRID is a free and open source relational database management engine. The power of CUBRID lies in its capability to support enterprise level features. It provides certain novel features in the form of object-oriented database element relations, a native
Databases are an integral part of any software application. The persistence that the databases bring in to the applications enable efficient retrievability of relevant data from nonvolatile storage. There are a large number of databases such as MySQL, MariaDB, CouchDB, etc. This article provides an overview of a powerful enterpriseready database management engine, termed CUBRID (pronounced ‘cuberid’).
The first appearance of CUBRID was in November 2008. The latest stable release is CUBRID 10.1, which was released in July 2017. It is written in the C language and supports two major operating systems—GNU/Linux and Windows.
The major features of CUBRID are:
Free and open source
Powerful
Offers enterprise features
CUBRID is completely free of cost. As it is open source, you can choose to customise it to your specific requirements. Its enterprise features are listed below.
High availability: The high availability of CUBRID is attributed to its powerful Heartbeat native engine. It works very accurately and has automatic failover technology, built in. Globalisation: CUBRID has excellent I18N (internationalisation) and L10N (localisation) features. Scalability and Big Data optimisation: CUBRID offers automatic volume expansion with support for multiple volumes.
High performance optimised for Web services: CUBRID has support for multithreaded and multiserver architecture. It has native broker middleware. The intensive caching feature that CUBRID offers is excellent.
Getting started with CUBRID
This section details the steps required to get started with the CUBRID database management engine. The overall process is illustrated in Figure 3.
Step 1: The first step is to download and install the CUBRID engine. The official Web page provides download links for both GNU/Linux and Windows (https://www.cubrid.org/downloads/ os-select/64-bit/engine). You can download the latest stable release of CUBRID 10.1 and execute the installer.
Step 2: After successful installation, you can start the CUBRID service by executing the following command in a terminal:
cubrid service start
Step 3: Once the CUBRID service is started, you can create and start using the databases. Two sample commands are shown below:
cubrid createdb osfytest en_US cubrid server start osfytest
Step 4: The next step is to connect to the database using CSQL. The command for doing that is as follows:
csql –user PUBLIC osfytest
Step 5: After the completion of all the above steps, you can run the required SQL queries.
CUBRID vs MySQL
As MySQL is a leading open source database management system (DBMS), you may get asked about their relative merits. First and foremost, CUBRID is not derived from MySQL. It is a separate RDBMS tool which has around 20 years of development history, as mentioned earlier.
Regarding performance, the official CUBRID documentation claims that it is faster than MySQL in scenarios when there are many concurrent requests. Unlike some other RDBMSs, CUBRID has no separate enterprise licence. It has only one flavour, which is under GPL version 2 or higher. Hence, CUBRID is completely free with all its enterprise level features.
CUBRID language support
CUBRID supports many popular programming languages. It does so by providing languagespecific APIs (Application Programming Interfaces). CUBRID is written in C and hence there is a native C driver. This driver is referred to as CCI. Apart from this, CUBRID has support for the following programming languages:
Java
PHP
Ruby
Python
Perl
Node.js
ADO.NET driver for .NET programming languages In this article, examples with two popular programming languages — Java and Python — are given.
A simple CUBRID example with Java
This section introduces you to a compact and standalone Java program that interacts with CUBRID. For this program to work, you should have already installed CUBRID, having followed the steps mentioned earlier, and it requires the JDBC driver as well. If your system doesn’t have it, then do install it. The installer is available at https://www.cubrid.org/ downloads/os-select/64-bit/drivers/jdbc--
package org.cubrid.demo; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import static java.sql.DriverManager.getConnection; public class Main { public static void main(String[] args) {
String url = “jdbc:cubrid:localhost:33000:demodb:publ ic::?charSet=utf8”; try { Class.forName(“cubrid.jdbc.driver.CUBRIDDriver”); Connection conn = getConnection(url, null, null); conn.setAutoCommit(false); try (Statement stmt = conn.createStatement()) { // Create a new table and insert some data stmt.execute(“drop table if exists mytable”); stmt.execute(“create table mytable(mycolumn string)”);
stmt.execute(“insert into mytable values(‘This is
my first inserted string’)”);
ResultSet rs = stmt.executeQuery(“select * from mytable”);
// Retrieve and output the table data while (rs.next()) { System.out.println(rs.getString(“mycolumn”)); } } conn.close();
} catch (Exception e) { e.printStackTrace(); }
}
}
This program can be compiled and executed, with the following two commands:
javac TestCUBRID.java java TestCUBRID
It can be easily inferred from the code that connecting and handling CUBRID is very similar to other databases.
So, if you have programmed for other databases in Java, you don’t need to learn anything extraordinary in order to work with CUBRID.
An example in Python
To manipulate the CUBRID database with Python, you need CUBRIDdb, which is the Python extension package. The CUBRID Python driver can be installed in various ways. The easiest of them is to go with easy_install. The simple command for performing this task is shown below:
easy_install CUBRID-Python A complete example with Python is shown below:
import CUBRIDdb conn = CUBRIDdb.connect(‘CUBRID:localhost:33000:demodb’, ‘public’, ‘’) cur = conn.cursor()
# Plain insert statement cur.execute(“INSERT INTO posts (id, title, body, last_ updated) VALUES (1, ‘Title 1’, ‘Test body #1’, CURRENT_ TIMESTAMP)”)
# Parameterized insert statement args = (2, ‘Title 2’, ‘Test body #2’) cur.execute(“INSERT INTO posts (id, title, body, last_ updated) VALUES (?, ?, ?, CURRENT_TIMESTAMP)”, args)
conn.commit()
The complete information about handling CUBRID with Python is available at https://www.python.org/dev/ peps/pep-0249/.
GUI tools for CUBRID
There are various graphical user interface tools available for handling CUBRID in an easier manner. These are listed in Table 1. CUBRID HA What ‘HA’ refers to is ‘high availability’. This is a feature that enables uninterrupted service in scenarios when there is failure in either the hardware, software or the network. CUBRID HA includes more than one server system. These are used to provide uninterrupted services when an individual server fails. CUBRID HA synchronises databases among multiple servers. This feature can be enabled for missioncritical applications when there is a need for 24/7 availability of service. More information on CUBRID HA is available at https://www.cubrid. org/manual/en/10.1/ha.html.
If you want to contribute to CUBRID RDBMS, then check out the source from https://github.com/CUBRID. Based on your expertise, you can get involved in contributing to the development of drivers, tools, content management systems (CMS), etc. Even as just a user, you can report bugs by opening issues in JIRA or by simply sending an email to bug@cubrid.org.
CUBRID is an actively maintained relational database engine. Recent updates on it are available at https://www. cubrid.org/blog. References [1] https://www.cubrid.org/ [2] https://www.cubrid.org/documentation By: Dr K.S.Kuppusamy The author is an assistant professor of computer science at Pondicherry Central University. He has 13+ years of teaching and research experience in academia and industry. He can be reached at kskuppu@gmail.com .