| 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 Berkeley DB is not</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_dbis.html" title="What is Berkeley DB?" /> |
| 12 | <link rel="next" href="intro_need.html" title="Do you need Berkeley DB?" /> |
| 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 Berkeley DB is not</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="intro_dbis.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_need.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_dbisnot"></a>What Berkeley DB is not</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <div class="toc"> |
| 42 | <dl> |
| 43 | <dt> |
| 44 | <span class="sect2"> |
| 45 | <a href="intro_dbisnot.html#idp50596256">Berkeley DB is not a relational database</a> |
| 46 | </span> |
| 47 | </dt> |
| 48 | <dt> |
| 49 | <span class="sect2"> |
| 50 | <a href="intro_dbisnot.html#idp50675392">Berkeley DB is not an object-oriented database</a> |
| 51 | </span> |
| 52 | </dt> |
| 53 | <dt> |
| 54 | <span class="sect2"> |
| 55 | <a href="intro_dbisnot.html#idp50621304">Berkeley DB is not a network database</a> |
| 56 | </span> |
| 57 | </dt> |
| 58 | <dt> |
| 59 | <span class="sect2"> |
| 60 | <a href="intro_dbisnot.html#idp50657008">Berkeley DB is not a database server</a> |
| 61 | </span> |
| 62 | </dt> |
| 63 | </dl> |
| 64 | </div> |
| 65 | <p> |
| 66 | In contrast to most other database systems, Berkeley DB provides relatively |
| 67 | simple data access services. |
| 68 | </p> |
| 69 | <p> |
| 70 | Records in Berkeley DB are (<span class="emphasis"><em>key</em></span>, |
| 71 | <span class="emphasis"><em>value</em></span>) pairs. Berkeley DB supports only a few |
| 72 | logical operations on records. They are: |
| 73 | </p> |
| 74 | <div class="itemizedlist"> |
| 75 | <ul type="disc"> |
| 76 | <li>Insert a record in a table.</li> |
| 77 | <li>Delete a record from a table.</li> |
| 78 | <li>Find a record in a table by looking up its key.</li> |
| 79 | <li>Update a record that has already been found.</li> |
| 80 | </ul> |
| 81 | </div> |
| 82 | <p> |
| 83 | Notice that Berkeley DB never operates on the value part of a |
| 84 | record. Values are simply payload, to be stored with keys and |
| 85 | reliably delivered back to the application on demand. |
| 86 | </p> |
| 87 | <p> |
| 88 | Both keys and values can be arbitrary byte strings, either |
| 89 | fixed-length or variable-length. As a result, programmers can put |
| 90 | native programming language data structures into the database |
| 91 | without converting them to a foreign record format first. Storage |
| 92 | and retrieval are very simple, but the application needs to know |
| 93 | what the structure of a key and a value is in advance. It cannot |
| 94 | ask Berkeley DB, because Berkeley DB doesn't know. |
| 95 | </p> |
| 96 | <p> |
| 97 | This is an important feature of Berkeley DB, and one worth |
| 98 | considering more carefully. On the one hand, Berkeley DB cannot |
| 99 | provide the programmer with any information on the contents or |
| 100 | structure of the values that it stores. The application must |
| 101 | understand the keys and values that it uses. On the other hand, |
| 102 | there is literally no limit to the data types that can be store in |
| 103 | a Berkeley DB database. The application never needs to convert its |
| 104 | own program data into the data types that Berkeley DB supports. |
| 105 | Berkeley DB is able to operate on any data type the application |
| 106 | uses, no matter how complex. |
| 107 | </p> |
| 108 | <p> |
| 109 | Because both keys and values can be up to four gigabytes in length, |
| 110 | a single record can store images, audio streams, or other large |
| 111 | data values. Large values are not treated specially in Berkeley |
| 112 | DB. They are simply broken into page-sized chunks, and reassembled |
| 113 | on demand when the application needs them. Unlike some other |
| 114 | database systems, Berkeley DB offers no special support for binary |
| 115 | large objects (BLOBs). |
| 116 | </p> |
| 117 | <div class="sect2" lang="en" xml:lang="en"> |
| 118 | <div class="titlepage"> |
| 119 | <div> |
| 120 | <div> |
| 121 | <h3 class="title"><a id="idp50596256"></a>Berkeley DB is not a relational database</h3> |
| 122 | </div> |
| 123 | </div> |
| 124 | </div> |
| 125 | <p> |
| 126 | While Berkeley DB does provide a set of optional SQL APIs, |
| 127 | usually all access to data stored in Berkeley DB is performed |
| 128 | using the traditional Berkeley DB APIs. |
| 129 | </p> |
| 130 | <p> |
| 131 | The traditional Berkeley DB APIs are the way that most Berkeley DB |
| 132 | users will use Berkeley DB. Although the |
| 133 | interfaces are fairly simple, they are non-standard in that they |
| 134 | do not support SQL statements. |
| 135 | </p> |
| 136 | <p> |
| 137 | That said, Berkeley DB does provide a set of SQL APIs that behave |
| 138 | nearly identically to SQLite. By using these APIs you can interface |
| 139 | with Berkeley DB using SQL statements. For Unix systems, these APIs |
| 140 | are not available by default, while for Windows systems they are |
| 141 | available by default. For more information, see the |
| 142 | <em class="citetitle">Berkeley DB Getting Started with the SQL APIs</em> guide. |
| 143 | </p> |
| 144 | <p> |
| 145 | Be aware that SQL support is a double-edged sword. One big advantage of |
| 146 | relational databases is that they allow users to write simple |
| 147 | declarative queries in a high-level language. The database system |
| 148 | knows everything about the data and can carry out the command. This |
| 149 | means that it's simple to search for data in new ways, and to ask |
| 150 | new questions of the database. No programming is required. |
| 151 | </p> |
| 152 | <p> |
| 153 | On the other hand, if a programmer can predict in advance how an |
| 154 | application will access data, then writing a low-level program to |
| 155 | get and store records can be faster. It eliminates the overhead of |
| 156 | query parsing, optimization, and execution. The programmer must |
| 157 | understand the data representation, and must write the code to do |
| 158 | the work, but once that's done, the application can be very fast. |
| 159 | </p> |
| 160 | <p> |
| 161 | Unless Berkeley DB is used with its SQL APIs, it has no notion of |
| 162 | <span class="emphasis"><em>schema</em></span> and data types in the way that |
| 163 | relational systems do. Schema is the structure of records in |
| 164 | tables, and the relationships among the tables in the database. For |
| 165 | example, in a relational system the programmer can create a record |
| 166 | from a fixed menu of data types. Because the record types are |
| 167 | declared to the system, the relational engine can reach inside |
| 168 | records and examine individual values in them. In addition, |
| 169 | programmers can use SQL to declare relationships among tables, and |
| 170 | to create indices on tables. Relational engines usually maintain |
| 171 | these relationships and indices automatically. |
| 172 | </p> |
| 173 | <p> |
| 174 | In Berkeley DB, the key and value in a record are opaque to |
| 175 | Berkeley DB. They may have a rich internal structure, but the |
| 176 | library is unaware of it. As a result, Berkeley DB cannot decompose |
| 177 | the value part of a record into its constituent parts, and cannot |
| 178 | use those parts to find values of interest. Only the application, |
| 179 | which knows the data structure, can do that. Berkeley DB does |
| 180 | support indices on tables and automatically maintain those indices |
| 181 | as their associated tables are modified. |
| 182 | </p> |
| 183 | <p> |
| 184 | Berkeley DB is not a relational system. Relational database systems |
| 185 | are semantically rich and offer high-level database access. |
| 186 | Compared to such systems, Berkeley DB is a high-performance, |
| 187 | transactional library for record storage. It is possible to build a |
| 188 | relational system on top of Berkeley DB (indeed, this is what the |
| 189 | Berkeley DB SQL API really is). In fact, the popular MySQL |
| 190 | relational system uses Berkeley DB for transaction-protected table |
| 191 | management, and takes care of all the SQL parsing and execution. It |
| 192 | uses Berkeley DB for the storage level, and provides the semantics |
| 193 | and access tools. |
| 194 | </p> |
| 195 | </div> |
| 196 | <div class="sect2" lang="en" xml:lang="en"> |
| 197 | <div class="titlepage"> |
| 198 | <div> |
| 199 | <div> |
| 200 | <h3 class="title"><a id="idp50675392"></a>Berkeley DB is not an object-oriented database</h3> |
| 201 | </div> |
| 202 | </div> |
| 203 | </div> |
| 204 | <p> |
| 205 | Object-oriented databases are designed for very tight integration |
| 206 | with object-oriented programming languages. Berkeley DB is written |
| 207 | entirely in the C programming language. It includes language |
| 208 | bindings for C++, Java, and other languages, but the library has no |
| 209 | information about the objects created in any object-oriented |
| 210 | application. Berkeley DB never makes method calls on any |
| 211 | application object. It has no idea what methods are defined on user |
| 212 | objects, and cannot see the public or private members of any |
| 213 | instance. The key and value part of all records are opaque to |
| 214 | Berkeley DB. |
| 215 | </p> |
| 216 | <p> |
| 217 | Berkeley DB cannot automatically page in objects as they are |
| 218 | accessed, as some object-oriented databases do. The object-oriented |
| 219 | application programmer must decide what records are required, and |
| 220 | must fetch them by making method calls on Berkeley DB objects. |
| 221 | </p> |
| 222 | </div> |
| 223 | <div class="sect2" lang="en" xml:lang="en"> |
| 224 | <div class="titlepage"> |
| 225 | <div> |
| 226 | <div> |
| 227 | <h3 class="title"><a id="idp50621304"></a>Berkeley DB is not a network database</h3> |
| 228 | </div> |
| 229 | </div> |
| 230 | </div> |
| 231 | <p> |
| 232 | Berkeley DB does not support network-style navigation among |
| 233 | records, as network databases do. Records in a Berkeley DB table |
| 234 | may move around over time, as new records are added to the table |
| 235 | and old ones are deleted. Berkeley DB is able to do fast searches |
| 236 | for records based on keys, but there is no way to create a |
| 237 | persistent physical pointer to a record. Applications can only |
| 238 | refer to records by key, not by address. |
| 239 | </p> |
| 240 | </div> |
| 241 | <div class="sect2" lang="en" xml:lang="en"> |
| 242 | <div class="titlepage"> |
| 243 | <div> |
| 244 | <div> |
| 245 | <h3 class="title"><a id="idp50657008"></a>Berkeley DB is not a database server</h3> |
| 246 | </div> |
| 247 | </div> |
| 248 | </div> |
| 249 | <p> |
| 250 | Berkeley DB is not a standalone database server. It is a library, |
| 251 | and runs in the address space of the application that uses it. If |
| 252 | more than one application links in Berkeley DB, then all can use |
| 253 | the same database at the same time; the library handles |
| 254 | coordination among the applications, and guarantees that they do |
| 255 | not interfere with one another. |
| 256 | </p> |
| 257 | <p> |
| 258 | It is possible to build a server application that uses Berkeley DB |
| 259 | for data management. For example, many commercial and open source |
| 260 | Lightweight Directory Access Protocol (LDAP) servers use Berkeley |
| 261 | DB for record storage. LDAP clients connect to these servers over |
| 262 | the network. Individual servers make calls through the Berkeley DB |
| 263 | API to find records and return them to clients. On its own, |
| 264 | however, Berkeley DB is not a server. |
| 265 | </p> |
| 266 | </div> |
| 267 | </div> |
| 268 | <div class="navfooter"> |
| 269 | <hr /> |
| 270 | <table width="100%" summary="Navigation footer"> |
| 271 | <tr> |
| 272 | <td width="40%" align="left"><a accesskey="p" href="intro_dbis.html">Prev</a> </td> |
| 273 | <td width="20%" align="center"> |
| 274 | <a accesskey="u" href="intro.html">Up</a> |
| 275 | </td> |
| 276 | <td width="40%" align="right"> <a accesskey="n" href="intro_need.html">Next</a></td> |
| 277 | </tr> |
| 278 | <tr> |
| 279 | <td width="40%" align="left" valign="top">What is Berkeley DB? </td> |
| 280 | <td width="20%" align="center"> |
| 281 | <a accesskey="h" href="index.html">Home</a> |
| 282 | </td> |
| 283 | <td width="40%" align="right" valign="top"> Do you need Berkeley DB?</td> |
| 284 | </tr> |
| 285 | </table> |
| 286 | </div> |
| 287 | </body> |
| 288 | </html> |