Debian Codegraph @

docs/programmer_reference/intro_dbis.html

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <title>What is Berkeley DB?</title>
7 <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9 <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
10 <link rel="up" href="intro.html" title="Chapter 1.  Introduction" />
11 <link rel="prev" href="intro_terrain.html" title="Mapping the terrain: theory and practice" />
12 <link rel="next" href="intro_dbisnot.html" title="What Berkeley DB is not" />
13 </head>
14 <body>
15 <div xmlns="" class="navheader">
16 <div class="libver">
17 <p>Library Version 11.2.5.3</p>
18 </div>
19 <table width="100%" summary="Navigation header">
20 <tr>
21 <th colspan="3" align="center">What is Berkeley DB?</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="intro_terrain.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 1. 
26 Introduction
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="intro_dbisnot.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="intro_dbis"></a>What is Berkeley DB?</h2>
38 </div>
39 </div>
40 </div>
41 <div class="toc">
42 <dl>
43 <dt>
44 <span class="sect2">
45 <a href="intro_dbis.html#idp50588152">Data Access Services</a>
46 </span>
47 </dt>
48 <dt>
49 <span class="sect2">
50 <a href="intro_dbis.html#idm1374112">Data management services</a>
51 </span>
52 </dt>
53 <dt>
54 <span class="sect2">
55 <a href="intro_dbis.html#idp50659944">Design</a>
56 </span>
57 </dt>
58 </dl>
59 </div>
60 <p>
61 So far, we have discussed database systems in general terms. It is
62 time now to consider Berkeley DB in particular and see how it fits
63 into the framework we have introduced. The key question is, what
64 kinds of applications should use Berkeley DB?
65 </p>
66 <p>
67 Berkeley DB is an Open Source embedded database library that
68 provides scalable, high-performance, transaction-protected data
69 management services to applications. Berkeley DB provides a simple
70 function-call API for data access and management.
71 </p>
72 <p>
73 By "Open Source," we mean Berkeley DB is distributed under a
74 license that conforms to the
75 <a class="ulink" href="http://www.opensource.org/osd.html" target="_top"> Open Source Definition</a>.
76 This license guarantees Berkeley DB is freely available for use and
77 redistribution in other Open Source applications. Oracle
78 Corporation sells commercial licenses allowing the redistribution
79 of Berkeley DB in proprietary applications. In all cases the
80 complete source code for Berkeley DB is freely available for
81 download and use.
82 </p>
83 <p>
84 Berkeley DB is "embedded" because it links directly into the
85 application. It runs in the same address space as the application.
86 As a result, no inter-process communication, either over the
87 network or between processes on the same machine, is required for
88 database operations. Berkeley DB provides a simple function-call
89 API for a number of programming languages, including C, C++, Java,
90 Perl, Tcl, Python, and PHP. All database operations happen inside
91 the library. Multiple processes, or multiple threads in a single
92 process, can all use the database at the same time as each uses the
93 Berkeley DB library. Low-level services like locking, transaction
94 logging, shared buffer management, memory management, and so on are
95 all handled transparently by the library.
96 </p>
97 <p>
98 The Berkeley DB library is extremely portable. It runs under almost
99 all UNIX and Linux variants, Windows, and a number of embedded
100 real-time operating systems. It runs on both 32-bit and 64-bit
101 systems. It has been deployed on high-end Internet servers,
102 desktop machines, and on palmtop computers, set-top boxes, in
103 network switches, and elsewhere. Once Berkeley DB is linked into
104 the application, the end user generally does not know that there is
105 a database present at all.
106 </p>
107 <p>
108 Berkeley DB is scalable in a number of respects. The database library
109 itself is quite compact (under 300 kilobytes of text space on common
110 architectures), which means it is small enough to run in tightly
111 constrained embedded systems, but yet it can take advantage of
112 gigabytes of memory and terabytes of disk if you are using hardware that
113 has those resources.
114 </p>
115 <p>
116 Each of Berkeley DB's database files can contain up to 256
117 terabytes of data, assuming the underlying filesystem is capable of supporting
118 files of that size. Note that Berkeley DB applications often use
119 multiple database files. This means that the amount of data your
120 Berkeley DB application can manage is really limited only by the
121 constraints imposed by your operating system, filesystem, and physical
122 hardware.
123 </p>
124 <p>
125 Berkeley DB also supports high concurrency, allowing thousands of users
126 to operate on the same database files at the same time.
127 </p>
128 <p>
129 Berkeley DB generally outperforms relational and object-oriented
130 database systems in embedded applications for a couple of reasons.
131 First, because the library runs in the same address space, no
132 inter-process communication is required for database operations.
133 The cost of communicating between processes on a single machine, or
134 among machines on a network, is much higher than the cost of making
135 a function call. Second, because Berkeley DB uses a simple
136 function-call interface for all operations, there is no query
137 language to parse, and no execution plan to produce.
138 </p>
139 <div class="sect2" lang="en" xml:lang="en">
140 <div class="titlepage">
141 <div>
142 <div>
143 <h3 class="title"><a id="idp50588152"></a>Data Access Services</h3>
144 </div>
145 </div>
146 </div>
147 <p>
148 Berkeley DB applications can choose the storage structure that
149 best suits the application. Berkeley DB supports hash tables,
150 Btrees, simple record-number-based storage, and persistent
151 queues. Programmers can create tables using any of these
152 storage structures, and can mix operations on different kinds
153 of tables in a single application.
154 </p>
155 <p>
156 Hash tables are generally good for very large databases that
157 need predictable search and update times for random-access
158 records. Hash tables allow users to ask, "Does this key
159 exist?" or to fetch a record with a known key. Hash tables do
160 not allow users to ask for records with keys that are close to
161 a known key.
162 </p>
163 <p>
164 Btrees are better for range-based searches, as when the
165 application needs to find all records with keys between some
166 starting and ending value. Btrees also do a better job of
167 exploiting <span class="emphasis"><em>locality of reference</em></span>. If the
168 application is likely to touch keys near each other at the same
169 time, the Btrees work well. The tree structure keeps keys that
170 are close together near one another in storage, so fetching
171 nearby values usually does not require a disk access.
172 </p>
173 <p>
174 Record-number-based storage is natural for applications that
175 need to store and fetch records, but that do not have a simple
176 way to generate keys of their own. In a record number table,
177 the record number is the key for the record. Berkeley DB will
178 generate these record numbers automatically.
179 </p>
180 <p>
181 Queues are well-suited for applications that create records,
182 and then must deal with those records in creation order. A good
183 example is on-line purchasing systems. Orders can enter the
184 system at any time, but should generally be filled in the order
185 in which they were placed.
186 </p>
187 </div>
188 <div class="sect2" lang="en" xml:lang="en">
189 <div class="titlepage">
190 <div>
191 <div>
192 <h3 class="title"><a id="idm1374112"></a>Data management services</h3>
193 </div>
194 </div>
195 </div>
196 <p>
197 Berkeley DB offers important data management services,
198 including concurrency, transactions, and recovery. All of these
199 services work on all of the storage structures.
200 </p>
201 <p>
202 Many users can work on the same database concurrently. Berkeley
203 DB handles locking transparently, ensuring that two users
204 working on the same record do not interfere with one
205 another.
206 </p>
207 <p>
208 The library provides strict ACID transaction semantics, by
209 default. However, applications are allowed to relax the
210 isolation guarantees the database system makes.
211 </p>
212 <p>
213 Multiple operations can be grouped into a single transaction,
214 and can be committed or rolled back atomically. Berkeley DB
215 uses a technique called <span class="emphasis"><em>two-phase locking</em></span>
216 to be sure that concurrent transactions are isolated from one
217 another, and a technique called <span class="emphasis"><em>write-ahead
218 logging</em></span> to guarantee that committed changes
219 survive application, system, or hardware failures.
220 </p>
221 <p>
222 When an application starts up, it can ask Berkeley DB to run
223 recovery. Recovery restores the database to a clean state,
224 with all committed changes present, even after a crash. The
225 database is guaranteed to be consistent and all committed
226 changes are guaranteed to be present when recovery
227 completes.
228 </p>
229 <p>
230 An application can specify, when it starts up, which data
231 management services it will use. Some applications need fast,
232 single-user, non-transactional Btree data storage. In that
233 case, the application can disable the locking and transaction
234 systems, and will not incur the overhead of locking or logging.
235 If an application needs to support multiple concurrent users,
236 but does not need transactions, it can turn on locking without
237 transactions. Applications that need concurrent,
238 transaction-protected database access can enable all of the
239 subsystems.
240 </p>
241 <p>
242 In all these cases, the application uses the same function-call
243 API to fetch and update records.
244 </p>
245 </div>
246 <div class="sect2" lang="en" xml:lang="en">
247 <div class="titlepage">
248 <div>
249 <div>
250 <h3 class="title"><a id="idp50659944"></a>Design</h3>
251 </div>
252 </div>
253 </div>
254 <p>
255 Berkeley DB was designed to provide industrial-strength
256 database services to application developers, without requiring
257 them to become database experts. It is a classic C-library
258 style <span class="emphasis"><em>toolkit</em></span>, providing a broad base of
259 functionality to application writers. Berkeley DB was designed
260 by programmers, for programmers: its modular design surfaces
261 simple, orthogonal interfaces to core services, and it provides
262 mechanism (for example, good thread support) without imposing
263 policy (for example, the use of threads is not required). Just
264 as importantly, Berkeley DB allows developers to balance
265 performance against the need for crash recovery and concurrent
266 use. An application can use the storage structure that
267 provides the fastest access to its data and can request only
268 the degree of logging and locking that it needs.
269 </p>
270 <p>
271 Because of the tool-based approach and separate interfaces for
272 each Berkeley DB subsystem, you can support a complete
273 transaction environment for other system operations. Berkeley
274 DB even allows you to wrap transactions around the standard
275 UNIX file read and write operations! Further, Berkeley DB was
276 designed to interact correctly with the native system's
277 toolset, a feature no other database package offers. For
278 example, on UNIX systems Berkeley DB supports hot backups
279 (database backups while the database is in use), using standard
280 UNIX system utilities, for example, dump, tar, cpio, pax or
281 even cp. On other systems which do not support filesystems
282 with read isolation, Berkeley DB provides a tool for safely
283 copying files.
284 </p>
285 <p>
286 Finally, because scripting language interfaces are available
287 for Berkeley DB (notably Tcl and Perl), application writers can
288 build incredibly powerful database engines with little effort.
289 You can build transaction-protected database applications using
290 your favorite scripting languages, an increasingly important
291 feature in a world using CGI scripts to deliver HTML.
292 </p>
293 </div>
294 </div>
295 <div class="navfooter">
296 <hr />
297 <table width="100%" summary="Navigation footer">
298 <tr>
299 <td width="40%" align="left"><a accesskey="p" href="intro_terrain.html">Prev</a> </td>
300 <td width="20%" align="center">
301 <a accesskey="u" href="intro.html">Up</a>
302 </td>
303 <td width="40%" align="right"> <a accesskey="n" href="intro_dbisnot.html">Next</a></td>
304 </tr>
305 <tr>
306 <td width="40%" align="left" valign="top">Mapping the terrain: theory and practice </td>
307 <td width="20%" align="center">
308 <a accesskey="h" href="index.html">Home</a>
309 </td>
310 <td width="40%" align="right" valign="top"> What Berkeley DB is not</td>
311 </tr>
312 </table>
313 </div>
314 </body>
315 </html>