Mnesia

Last updated
Mnesia
Original author(s) Joe Armstrong, Robert Virding, Dan Gudmundsson and others
Developer(s) Ericsson
Stable release
4.15.4 / June 19, 2018 (2018-06-19)
Written in Erlang
Operating system Cross-platform
Platform Cross-platform
Type Relational Database Management System
License Apache License 2.0 (since OTP 18.0)
Website www.erlang.org/doc/man/mnesia.html
LYME (software bundle) is based on Erlang and comprises Mnesia. It is entirely composed of free and open-source software LYME software bundle.svg
LYME (software bundle) is based on Erlang and comprises Mnesia. It is entirely composed of free and open-source software

Mnesia is a distributed, soft real-time database management system written in the Erlang programming language. [1] It is distributed as part of the Open Telecom Platform.

Contents

Description

As with Erlang, Mnesia was developed by Ericsson for soft real-time distributed and high-availability computing work related to telecoms. It was not intended as a general office-based data processing database management system, nor to replace SQL-based systems. Instead Mnesia exists to support Erlang, where DBMS-like persistence is required. [2] It has more in common with embeddable DBMS such as Berkeley DB than with any SQL database server.

Database model

"Rows" in tables are represented as records that contain a key value and a data field. This data field may in turn be a tuple containing an Erlang data structure of any complexity.

Backend types

Mnesia has three inbuilt table types: ram_copies, disc_copies and disc_only_copies.

Ram_copies

Data resides in memory and table size is limited by available memory and are backed by ETS (erlang term storage) table.

Disc_copies

Data resides in memory but is also persisted on disk backed by disk_log. Disc_copies were backed by Dets tables until 30th September 2001 with the release of Erlang R7B-4. [3]

Disc_only_copies

Data resides only on disc and are backed by Dets (disk version of ETS). [4] Dets file format uses signed 32-bit integers for file offsets and has a limit of 2 GB so do disc_only_copies. [3]

Backend plugins

Due to limits imposed by Dets, support for other backend plugins was suggested by Ulf Wiger [5] and these were added to Mnesia. Klarna added the LevelDB backend plugin [6] while Aeternity added the RocksDB backend plugin. [7]

Relational features

The database model is relational, but isn't what someone familiar with SQL might expect. A database contains tables. Relationships between them are modelled as other tables. [8]

A key feature of Mnesia's high-availability approach is that tables can be reconfigured within a schema and relocated between nodes, not only while the database is still running, but even while write operations are still going on.

Coding

The query language of Mnesia is Erlang itself, rather than SQL. [9] It permits easy representation of transactions as a natural feature of Erlang by allowing developers to utilize a single language throughout an application.

Transactions

Erlang is a functional language. Mnesia builds on this to obtain ACID transaction support. The functional block which is run as a transaction is a commonplace Erlang construct called a Functional Object (or Fun) [10] and is called by the single Mnesia statement mnesia:transaction(F). This can lead to clearer source code than the paired BEGIN / COMMIT syntax of SQL, and so avoids its problem of unclosed transactions within a procedure.

Again as a result of the functional nature of Erlang, nesting transactions is simple. It's also possible to distribute transactions across multiple nodes (i.e. separate servers). The semantics of using transactions in this way remains consistent, making it easy to write library code that works equally in either context.

General coding style for Mnesia will always use transactions. For performance reasons, it also supports deliberate "dirty operations" which avoid transactions. These compromise the atomicity and the isolation properties of ACID, but offer around 10× more throughput. [11] In addition there are also in-memory alternatives, although these lose the durability property of ACID.

Efficient execution

Mnesia forms part of the LYME web application stack. This is akin to LAMP, but based on Erlang. Implementation in Erlang confers an efficiency benefit because of the use of a single virtual machine throughout an application. LYME makes use of this, since the Yaws web server is also implemented in Erlang.

Address space is shared (although safely so, under Erlang) between code and data, including Mnesia's table data. [1] [12]

Origins and licensing

Mnesia and Erlang were developed by the Ericsson Computer Science Laboratory. They have been released as open source software. Mnesia is released under a derivative of the Mozilla Public License. [13] Since OTP 18.0 they are published according to the open source Apache License 2.0. Versions before OTP 18.0 were published under the open source Erlang Public License. [14]

ejabberd

Mnesia is also an option embedded within the Erlang-based Jabber daemon, ejabberd. [15]

See also

Related Research Articles

<span class="mw-page-title-main">Database</span> Organized collection of data in computing

In computing, a database is an organized collection of data stored and accessed electronically through the use of a database management system. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage. The design of databases spans formal techniques and practical considerations, including data modeling, efficient data representation and storage, query languages, security and privacy of sensitive data, and distributed computing issues, including supporting concurrent access and fault tolerance.

<span class="mw-page-title-main">MySQL</span> SQL database engine software

MySQL is an open-source relational database management system (RDBMS). Its name is a combination of "My", the name of co-founder Michael Widenius's daughter My, and "SQL", the acronym for Structured Query Language. A relational database organizes data into one or more data tables in which data may be related to each other; these relations help structure the data. SQL is a language that programmers use to create, modify and extract data from the relational database, as well as control user access to the database. In addition to relational databases and SQL, an RDBMS like MySQL works with an operating system to implement a relational database in a computer's storage system, manages users, allows for network access and facilitates testing database integrity and creation of backups.

<span class="mw-page-title-main">Ingres (database)</span>

Ingres Database is a proprietary SQL relational database management system intended to support large commercial and government applications.

<span class="mw-page-title-main">MonetDB</span>

MonetDB is an open-source column-oriented relational database management system (RDBMS) originally developed at the Centrum Wiskunde & Informatica (CWI) in the Netherlands. It is designed to provide high performance on complex queries against large databases, such as combining tables with hundreds of columns and millions of rows. MonetDB has been applied in high-performance applications for online analytical processing, data mining, geographic information system (GIS), Resource Description Framework (RDF), text retrieval and sequence alignment processing.

In computing, a solution stack or software stack is a set of software subsystems or components needed to create a complete platform such that no additional software is needed to support applications. Applications are said to "run on" or "run on top of" the resulting platform.

<span class="mw-page-title-main">Virtuoso Universal Server</span> Computer software

Virtuoso Universal Server is a middleware and database engine hybrid that combines the functionality of a traditional relational database management system (RDBMS), object–relational database (ORDBMS), virtual database, RDF, XML, free-text, web application server and file server functionality in a single system. Rather than have dedicated servers for each of the aforementioned functionality realms, Virtuoso is a "universal server"; it enables a single multithreaded server process that implements multiple protocols. The free and open source edition of Virtuoso Universal Server is also known as OpenLink Virtuoso. The software has been developed by OpenLink Software with Kingsley Uyi Idehen and Orri Erling as the chief software architects.

The SQuirreL SQL Client is a database administration tool. It uses JDBC to allow users to explore and interact with databases via a JDBC driver. It provides an editor that offers code completion and syntax highlighting for standard SQL. It also provides a plugin architecture that allows plugin writers to modify much of the application's behavior to provide database-specific functionality or features that are database-independent. As this desktop application is written entirely in Java with Swing UI components, it should run on any platform that has a JVM.

An embedded database system is a database management system (DBMS) which is tightly integrated with an application software; it is embedded in the application. It is a broad technology category that includes:

<span class="mw-page-title-main">Drizzle (database server)</span>

Drizzle is a discontinued free software/open-source relational database management system (DBMS) that was forked from the now-defunct 6.0 development branch of the MySQL DBMS.

<span class="mw-page-title-main">LYME (software bundle)</span>

LYME and LYCE are software stacks composed entirely of free and open-source software to build high-availability heavy duty dynamic web pages. The stacks are composed of:

OTP is a collection of useful middleware, libraries, and tools written in the Erlang programming language. It is an integral part of the open-source distribution of Erlang. The name OTP was originally an acronym for Open Telecom Platform, which was a branding attempt before Ericsson released Erlang/OTP as open source. However neither Erlang nor OTP is specific to telecom applications.

LevelDB is an open-source on-disk key-value store written by Google fellows Jeffrey Dean and Sanjay Ghemawat. Inspired by Bigtable, LevelDB is hosted on GitHub under the New BSD License and has been ported to a variety of Unix-based systems, macOS, Windows, and Android.

Aerospike Database is a flash memory and in-memory open source distributed key value NoSQL database management system, marketed by the company also named Aerospike.

Elliptics is a distributed key–value data storage with open source code. By default it is a classic distributed hash table (DHT) with multiple replicas put in different groups. Elliptics was created to meet requirements of multi-datacenter and physically distributed storage locations when storing huge amount of medium and large files.

Lightning Memory-Mapped Database (LMDB) is a software library that provides an embedded transactional database in the form of a key-value store. LMDB is written in C with API bindings for several programming languages. LMDB stores arbitrary key/data pairs as byte arrays, has a range-based search capability, supports multiple data items for a single key and has a special mode for appending records (MDB_APPEND) without checking for consistency. LMDB is not a relational database, it is strictly a key-value store like Berkeley DB and dbm.

SequoiaDB is a multi-model NewSQL database.

The following outline is provided as an overview of and topical guide to MySQL:

<span class="mw-page-title-main">RocksDB</span>

RocksDB is a high performance embedded database for key-value data. It is a fork of Google's LevelDB optimized to exploit multi-core processors (CPUs), and make efficient use of fast storage, such as solid-state drives (SSD), for input/output (I/O) bound workloads. It is based on a log-structured merge-tree data structure. It is written in C++ and provides official language bindings for C++, C, and Java. Many third-party language bindings exist. RocksDB is free and open-source software, released originally under a BSD 3-clause license. However, in July 2017 the project was migrated to a dual license of both Apache 2.0 and GPLv2 license, possibly in response to the Apache Software Foundation's blacklist of the previous BSD+Patents license clause.

<span class="mw-page-title-main">Hoodie (software)</span>

In computing, Hoodie is an open-source JavaScript package, that enables offline-first, front-end web development by providing a complete backend infrastructure. It aims to allow developers to rapidly develop web applications using only front-end code by providing a backend based on Node.js and Apache CouchDB. It runs on many Unix-like systems as well as on Microsoft Windows.

YDB (Yet another DataBase) is a distributed SQL database management system (DBMS) developed by Yandex, available as open-source technology.

References

  1. 1 2 Håkan Mattsson; Hans Nilsson; Claes Wikstrom (1999). "Mnesia - A Distributed Robust DBMS for Telecommunications Applications" (PDF). Archived from the original (PDF) on 2021-09-22. Retrieved 2008-09-25.
  2. "Purpose of Mnesia". Open-source Erlang project.
  3. 1 2 "Erlang -- Mnesia Database Questions". www.erlang.org. Retrieved 2021-11-05.
  4. "Erlang -- Mnesia Reference Manual". www.erlang.org. Retrieved 2021-11-05.
  5. mnesia_rocksdb, æternity, 2021-10-18, retrieved 2021-11-05
  6. mnesia_eleveldb, Klarna AB, 2021-11-03, retrieved 2021-11-05
  7. mnesia_rocksdb, æternity, 2021-10-18, retrieved 2021-11-05
  8. "Mnesia Getting Started guide". Open-source Erlang project.
  9. "Mnesia Reference Manual (v 4.4.5)". Open-source Erlang project.
  10. "6.17 Fun Expressions". Open-source Erlang project.
  11. Gavin Terrill (20 August 2007). "Erlang's Mnesia - a distributed DBMS for highly scalable apps". InfoQ.
  12. "Mnesia performance basics". Archived from the original on 2012-12-02. Retrieved 2008-09-25.
  13. "About Erlang". Open-source Erlang project.
  14. "Erlang Public License, V 1.1". Open-source Erlang project.
  15. "ejabberd project homepage".