File: Mnesia_chap1.html

package info (click to toggle)
erlang-doc-html 1%3A11.b.2-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 23,284 kB
  • ctags: 10,724
  • sloc: erlang: 505; ansic: 323; makefile: 62; perl: 61; sh: 45
file content (438 lines) | stat: -rw-r--r-- 10,596 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- This document was generated using DocBuilder 3.3.3 -->
<HTML>
<HEAD>
  <TITLE>Introduction
</TITLE>
  <SCRIPT type="text/javascript" src="../../../../doc/erlresolvelinks.js">
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#FF00FF"
      ALINK="#FF0000">
<CENTER>
<A HREF="http://www.erlang.se"><IMG BORDER=0 ALT="[Ericsson AB]" SRC="min_head.gif"></A>
</CENTER>
<A NAME="1"><!-- Empty --></A>
<H2>1 Introduction
</H2>

<P>This book describes the Mnesia DataBase Management
System (DBMS). <STRONG>Mnesia</STRONG> is a distributed Database Management
System, appropriate for telecommunications applications and other
Erlang applications which require continuous operation and soft
real-time properties. It is one section of the Open Telecom Platform
(OTP), which is a control system platform for building
telecommunications applications.
<A NAME="1.1"><!-- Empty --></A>
<H3>1.1 About Mnesia</H3>

<P> The management of data in telecommunications system has many
aspects whereof some, but not all, are addressed by traditional
commercial DBMSs (Data Base Management Systems). In particular the
very high level of fault tolerance which is required in many nonstop
systems, combined with requirements on the DBMS to run in the same
address space as the application, have led us to implement a brand new
DBMS. called Mnesia. Mnesia is implemented in, and very tightly
connected to, the programming language Erlang and it provides the
functionality that is necessary for the implementation of fault 
tolerant telecommunications systems. Mnesia is a multiuser Distributed
DBMS specially made for industrial telecommunications applications
written in the symbolic programming language Erlang, which is also 
the intended target language. Mnesia tries to address all of the data
management issues required for typical telecommunications systems and
it has a number of features that are not normally found in traditional
databases.<BR>

In telecommunications applications there are different needs 
from the features provided by traditional DBMSs. The applications now
implemented in the Erlang language need a mixture of a broad range
of features, which generally are not satisfied by traditional DBMSs.
Mnesia is designed with requirements like the following in mind:
<P>
<OL>

<LI>
Fast real-time key/value lookup
</LI>


<LI>
Complicated non real-time queries mainly for
operation and maintenance
</LI>


<LI>
Distributed data due to distributed 
applications
</LI>


<LI>
High fault tolerance
</LI>


<LI>
Dynamic re-configuration
</LI>


<LI>
Complex objects
</LI>


</OL>

<P> What
sets Mnesia apart from most other DBMSs is that it is designed with
the typical data management problems of telecommunications applications
in mind. Hence Mnesia combines many concepts found in traditional
databases, such as transactions and queries with concepts found in data
management systems for telecommunications applications, such as very
fast real-time operations, configurable degree of fault tolerance (by
means of replication) and the ability to reconfigure the system without
stopping or suspending it. Mnesia is also interesting due to its tight
coupling to the programming language Erlang, thus almost turning Erlang
into a database programming language. This has many benefits, the
foremost is that
the impedance mismatch between data format used by the
DBMS and data format used by the programming language, which is used
to manipulate the data, completely disappears.<BR>


<A NAME="1.2"><!-- Empty --></A>
<H3>1.2 The Mnesia DataBase Management System (DBMS)</H3>

<P><A NAME="1.2.1"><!-- Empty --></A>
<H4>1.2.1  Features</H4>

<P>Mnesia contains the following features which combine to produce a fault-tolerant,
        distributed database management system written in Erlang:


<P>
<UL>

<LI>
Database schema can be dynamically reconfigured at runtime.


</LI>


<LI>
Tables can be declared to have properties such as location, 
replication, and persistence.


</LI>


<LI>
Tables can be moved or replicated to several nodes to improve 
fault tolerance. The rest of the system can still access the tables 
to read, write, and delete records.


</LI>


<LI>
Table locations are transparent to the programmer. 
Programs address table names and the system itself keeps track of 
table locations.




</LI>


<LI>
Database transactions can be distributed, and a large number of 
functions can be called within one transaction.


</LI>


<LI>
Several transactions can run concurrently, and their execution is 
fully synchronized by the database management system. 
Mnesia ensures that no two processes manipulate data simultaneously.


</LI>


<LI>
Transactions can be assigned the property of being executed on 
all nodes in the system, or on none. Transactions can also be bypassed 
in favor of running so called &#34;dirty operations&#34;, which reduce 
overheads and run very fast.


</LI>


</UL>

<P>Details of these features are described in the following sections.

<P><A NAME="1.2.2"><!-- Empty --></A>
<H4>1.2.2  Add-on Applications</H4>

<P> QLC and Mnesia Session can be used in conjunction with Mnesia to produce 
        specialized functions which enhance the operational ability of Mnesia. 
        Both Mnesia Session and QLC have their own documentation as part
        of the OTP documentation set. Below are the main features of Mnesia Session
        and QLC when used in conjunction with Mnesia:

<P>
<UL>

<LI>
<STRONG>QLC</STRONG> has the ability to optimize the query
         compiler for the Mnesia Database Management System, essentially making
         the DBMS more efficient.
</LI>


<LI>
<STRONG>QLC</STRONG>, can be used as a database programming
language for Mnesia. It includes a notation called &#34;list
comprehensions&#34; and can be used to make complex database
queries over a set of tables.
</LI>


<LI>
<STRONG>Mnesia Session</STRONG> is an interface for the Mnesia Database 
         Management System
</LI>


<LI>
<STRONG>Mnesia Session</STRONG> enables access to the
         Mnesia DBMS from foreign programming languages (i.e. other
         languages than Erlang).
         
</LI>


</UL>

<P>

<A NAME="1.2.2.1"><!-- Empty --></A>
<H5>1.2.2.1 When to Use Mnesia</H5>

<P>Use Mnesia with the following types of applications:


<P>
<UL>

<LI>
Applications that need to replicate data.


</LI>


<LI>
Applications that perform complicated searches on data.


</LI>


<LI>
Applications that need to use atomic transactions to 
update several records simultaneously.

         
</LI>


<LI>
Applications that use soft real-time characteristics.


</LI>


</UL>

<P>On the other hand, Mnesia may not be appropriate with the 
following types of applications:


<P>
<UL>

<LI>
Programs that process plain text or binary data files


</LI>


<LI>
Applications that merely need a look-up dictionary
which can be stored to disc can utilize the standard
library module <CODE>dets</CODE>, which is a disc based version
of the module <CODE>ets</CODE>. 

         
</LI>


<LI>
Applications which need disc logging facilities can
utilize the module <CODE>disc_log</CODE> by preference.


</LI>


<LI>
Not suitable for hard real time systems.



</LI>


</UL>
<A NAME="1.2.3"><!-- Empty --></A>
<H4>1.2.3 Scope and Purpose</H4>

<P>This manual is included in the OTP document set. It describes
how to build Mnesia database applications, and how to integrate
and utilize the Mnesia database management system with
OTP. Programming constructs are described, and numerous
programming examples are included to illustrate the use of
Mnesia.

<A NAME="1.2.4"><!-- Empty --></A>
<H4>1.2.4 Prerequisites</H4>

<P>Readers of this manual are assumed to be familiar with system
development principles and database management systems. Readers
are also assumed to be familiar with the Erlang programming
language.
<A NAME="1.2.5"><!-- Empty --></A>
<H4>1.2.5 About This Book</H4>

<P>This book contains the following chapters:


<P>
<UL>

<LI>
Chapter 2, &#34;Getting Started with Mnesia&#34;, introduces
         Mnesia with an example database. Examples are shown of 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.



</LI>


<LI>
Chapter 3, &#34;Building a Mnesia Database&#34;, more formally
         describes the steps introduced in Chapter 2, namely the Mnesia
         functions which define a database schema, start Mnesia, and
         create the required tables.



</LI>


<LI>
Chapter 4, &#34;Transactions and other access contexts&#34;,
         describes the transactions properties which make Mnesia into a
         fault tolerant, real-time distributed database management
         system. This chapter also describes the concept of locking in
         order to ensure consistency in tables, and so called &#34;dirty
         operations&#34;, or short cuts which bypass the transaction system
         to improve speed and reduce overheads.


</LI>


<LI>
Chapter 5, &#34;Miscellaneous Mnesia Features&#34;, describes
         features which enable the construction of more complex
         database applications. These features includes indexing,
         checkpoints, distribution and fault tolerance, disc-less
nodes, replication manipulation, local content tables, concurrency,
         and object based programming in Mnesia.


</LI>


<LI>
Chapter 6, &#34;Mnesia System Information&#34;, 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.


</LI>


<LI>
Chapter 7, &#34;Combining Mnesia with SNMP&#34;, is a short
         chapter which outlines Mnesia integrated with SNMP.
         

        
</LI>


<LI>
Appendix A, &#34;Mnesia Errors Messages&#34;, lists Mnesia error
         messages and their meanings.

        
</LI>


<LI>
Appendix B, &#34;The Backup Call Back Interface&#34;, is a
         program listing of the default implementation of this facility.

        
</LI>


<LI>
Appendix C, &#34;The Activity Access Call Back Interface&#34;,
         is a program outlining of one possible implementations of this facility.


</LI>


</UL>
<CENTER>
<HR>
<SMALL>
Copyright &copy; 1991-2006
<A HREF="http://www.erlang.se">Ericsson AB</A><BR>
</SMALL>
</CENTER>
</BODY>
</HTML>