Mnesia

User's Guide

Version 4.15.3

- User's Guide
- Reference Manual
- Release Notes
- PDF
- Top

- Expand All
- Contract All

### Chapters

- Introduction
  - Top of chapter
  - Scope
  - Prerequisites
- Mnesia
  - Top of chapter
  - Mnesia Database Management System (DBMS)
- Getting Started
  - Top of chapter
  - Starting Mnesia for the First Time
  - Example
- Build a Mnesia Database
  - Top of chapter
  - Define a Schema
  - Data Model
  - Start Mnesia
  - Create Tables
- Transactions and Other Access Contexts
  - Top of chapter
  - Transaction Properties
  - Locking
  - Dirty Operations
  - Record Names versus Table Names
  - Activity Concept and Various Access Contexts
  - Nested Transactions
  - Pattern Matching
  - Iteration
- Miscellaneous Mnesia Features
  - Top of chapter
  - Indexing
  - Distribution and Fault Tolerance
  - Table Fragmentation
  - Local Content Tables
  - Disc-Less Nodes
  - More about Schema Management
  - Mnesia Event Handling
  - Debugging Mnesia Applications
  - Concurrent Processes in Mnesia
  - Prototyping
  - Object-Based Programming with Mnesia
- Mnesia System Information
  - Top of chapter
  - Database Configuration Data
  - Core Dumps
  - Dumping Tables
  - Checkpoints
  - Startup Files, Log File, and Data Files
  - Loading Tables at Startup
  - Recovery from Communication Failure
  - Recovery of Transactions
  - Backup, Restore, Fallback, and Disaster Recovery
- Combine Mnesia with SNMP
  - Top of chapter
  - Combine Mnesia and SNMP
- Appendix A: Backup Callback Interface
  - Top of chapter
  - mnesia_backup Callback Behavior
- Appendix B: Activity Access Callback Interface
  - Top of chapter
  - mnesia_access Callback Behavior
- Appendix C: Fragmented Table Hashing Callback Interface
  - Top of chapter
  - mnesia_frag_hash Callback Behavior

# 1 Introduction

The Mnesia application provides a heavy duty real-time distributed database.

### 1.1 Scope

This User's Guide describes how to build Mnesia database applications, and how to integrate and use the Mnesia database management system with OTP. Programming constructs are described, and numerous programming examples are included to illustrate the use of Mnesia.

This User's Guide is organized as follows:

- Mnesia provides an introduction to Mnesia.
- Getting Started introduces Mnesia with an example database. Examples are included how to start an Erlang session, specify a Mnesia database directory, initialize a database schema, start Mnesia, and create tables. Initial prototyping of record definitions is also discussed.
- Build a Mnesia Database more formally describes the steps introduced in the previous section, namely the Mnesia functions that define a database schema, start Mnesia, and create the required tables.
- Transactions and Other Access Contexts describes the transactions properties that make Mnesia into a fault tolerant, real-time distributed database management system. This section also describes the concept of locking to ensure consistency in tables, and "dirty operations", or short cuts, which bypass the transaction system to improve speed and reduce overheads.
- Miscellaneous Mnesia Features describes features that enable the construction of more complex database applications. These features include indexing, checkpoints, distribution and fault tolerance, disc-less nodes, replication manipulation, local content tables, concurrency, and object-based programming in Mnesia.
- Mnesia System Information describes the files contained in the Mnesia database directory, database configuration data, core and table dumps, as well as the important subject of backup, fall-back, and disaster recovery principles.
- Combine Mnesia with SNMP is a short section that outlines Mnesia integrated with SNMP.
- Appendix A: Backup Callback Interface is a program listing of the default implementation of this facility.
- Appendix B: Activity Access Callback Interface is a program outlining one possible implementation of this facility.
- Appendix C: Fragmented Table Hashing Callback Interface is a program outlining one possible implementation of this facility.

### 1.2 Prerequisites

It is assumed that the reader is familiar with the Erlang programming language, system development principles, and database management systems.