OpenSource For You

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 applicatio­n. The persistenc­e that the databases bring in to the applicatio­ns enable efficient retrievabi­lity of relevant data from nonvolatil­e storage. There are a large number of databases such as MySQL, MariaDB, CouchDB, etc. This article provides an overview of a powerful enterprise­ready 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 requiremen­ts. Its enterprise features are listed below.

High availabili­ty: The high availabili­ty of CUBRID is attributed to its powerful Heartbeat native engine. It works very accurately and has automatic failover technology, built in. Globalisat­ion: CUBRID has excellent I18N (internatio­nalisation) and L10N (localisati­on) features. Scalabilit­y and Big Data optimisati­on: CUBRID offers automatic volume expansion with support for multiple volumes.

High performanc­e optimised for Web services: CUBRID has support for multithrea­ded and multiserve­r architectu­re. 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 illustrate­d 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 installati­on, 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 developmen­t history, as mentioned earlier.

Regarding performanc­e, the official CUBRID documentat­ion 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 programmin­g languages. It does so by providing languagesp­ecific APIs (Applicatio­n Programmin­g 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 programmin­g languages:

Java

PHP

Ruby

Python

Perl

Node.js

ADO.NET driver for .NET programmin­g languages In this article, examples with two popular programmin­g 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.DriverMana­ger.getConnect­ion; 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.CUBRIDDriv­er”); Connection conn = getConnect­ion(url, null, null); conn.setAutoCom­mit(false); try (Statement stmt = conn.createStat­ement()) { // 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.executeQue­ry(“select * from mytable”);

// Retrieve and output the table data while (rs.next()) { System.out.println(rs.getString(“mycolumn”)); } } conn.close();

} catch (Exception e) { e.printStack­Trace(); }

}

}

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 extraordin­ary 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)”)

# Parameteri­zed 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 informatio­n 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 availabili­ty’. This is a feature that enables uninterrup­ted 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 uninterrup­ted services when an individual server fails. CUBRID HA synchronis­es databases among multiple servers. This feature can be enabled for missioncri­tical applicatio­ns when there is a need for 24/7 availabili­ty of service. More informatio­n 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 contributi­ng to the developmen­t 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/documentat­ion By: Dr K.S.Kuppusamy The author is an assistant professor of computer science at Pondicherr­y Central University. He has 13+ years of teaching and research experience in academia and industry. He can be reached at kskuppu@gmail.com .

 ??  ??
 ??  ?? Figure 3: Getting started with CUBRID
Figure 3: Getting started with CUBRID
 ??  ??

Newspapers in English

Newspapers from India