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
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Developing a DB Collections Application</title>
<link rel="stylesheet" href="gettingStarted.css" type="text/css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
<link rel="start" href="index.html" title="Berkeley DB Collections Tutorial" />
<link rel="up" href="intro.html" title="Chapter 1. Introduction" />
<link rel="prev" href="intro.html" title="Chapter 1. Introduction" />
<link rel="next" href="tutorialintroduction.html" title="Tutorial Introduction" />
</head>
<body>
<div xmlns="" class="navheader">
<div class="libver">
<p>Library Version 11.2.5.3</p>
</div>
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">Developing a DB Collections Application</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="intro.html">Prev</a> </td>
<th width="60%" align="center">Chapter 1.
Introduction
</th>
<td width="20%" align="right"> <a accesskey="n" href="tutorialintroduction.html">Next</a></td>
</tr>
</table>
<hr />
</div>
<div class="sect1" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a id="developing"></a>Developing a DB Collections Application</h2>
</div>
</div>
</div>
<p>
There are several important choices to make when developing an
application using the DB Java Collections API.
</p>
<div class="orderedlist">
<ol type="1">
<li>
<p>
Choose the Berkeley DB Environment
</p>
<p>
Depending on your application's concurrency and transactional
requirements, you may choose one of the three Berkeley DB
Environments: Data Store, Concurrent Data Store, or
Transactional Data Store. For details on creating and
configuring the environment, see the
<em class="citetitle">Berkeley DB Programmer's Reference Guide</em>
</p>
</li>
<li>
<p>
Choose the Berkeley DB Access Method
</p>
<p>
For each Berkeley DB datastore, you may choose from any of the
four Berkeley DB access methods — BTREE, HASH, RECNO, or
QUEUE
<span class="html">
(<a class="ulink" href="../../java/com/sleepycat/db/DatabaseType.html#BTREE" target="_top">DatabaseType.BTREE</a>,
<a class="ulink" href="../../java/com/sleepycat/db/DatabaseType.html#HASH" target="_top">DatabaseType.HASH</a>,
<a class="ulink" href="../../java/com/sleepycat/db/DatabaseType.html#RECNO" target="_top">DatabaseType.RECNO</a>,
or
<a class="ulink" href="../../java/com/sleepycat/db/DatabaseType.html#QUEUE" target="_top">DatabaseType.QUEUE</a>.)
</span>
— and a number of other database options. Your choice
depends on several factors such as whether you need ordered
keys, unique keys, record number access, and so forth. For more
information on access methods, see the
<em class="citetitle">Berkeley DB Programmer's Reference Guide</em>.
</p>
</li>
<li>
<p>
Choose the Format for Keys and Values
</p>
<p>
For each database you may choose a binding format for the keys
and values. For example, the tuple format is useful for keys
because it has a deterministic sort order. The serial format is
useful for values if you want to store arbitrary Java objects. In
some cases a custom format may be appropriate. For details on
choosing a binding format see
<a class="xref" href="collectionOverview.html#UsingDataBindings" title="Using Data Bindings">
Using Data Bindings
</a>.
</p>
</li>
<li>
<p>
Choose the Binding for Keys and Values
</p>
<p>
With the serial data format you do not have to create a binding
for each Java class that is stored since Java serialization is
used. But for other formats a binding must be defined that
translates between stored byte arrays and Java objects. For details
see
<a class="xref" href="collectionOverview.html#UsingDataBindings" title="Using Data Bindings">
Using Data Bindings
</a>.
</p>
</li>
<li>
<p>
Choose Secondary Indices
</p>
<p>
Any database that has unique keys may have any number of
secondary indices. A secondary index has keys that are derived from
data values in the primary database. This allows lookup and
iteration of objects in the database by its index keys.
For each index you must define how the index keys are derived from the data
values using a
<span>
<a class="ulink" href="../../java/com/sleepycat/db/SecondaryKeyCreator.html" target="_top">SecondaryKeyCreator</a>.
</span>
For details see the
<span>
<a class="ulink" href="../../java/com/sleepycat/db/SecondaryDatabase.html" target="_top">SecondaryDatabase</a>,
</span>
<a class="ulink" href="../../java/com/sleepycat/db/SecondaryConfig.html" target="_top">SecondaryConfig</a>
and
<a class="ulink" href="../../java/com/sleepycat/db/SecondaryKeyCreator.html" target="_top">SecondaryKeyCreator</a>
classes.
</p>
</li>
<li>
<p>
Choose the Collection Interface for each Database
</p>
<p>
The standard Java Collection interfaces are used for accessing
databases and secondary indices. The Map and Set interfaces may be
used for any type of database. The Iterator interface is used
through the Set interfaces. For more information on the collection
interfaces see
<a class="xref" href="UsingStoredCollections.html" title="Using Stored Collections">
Using Stored Collections
</a>.
</p>
</li>
</ol>
</div>
<p>
Any number of bindings and collections may be created for the
same database. This allows multiple views of the same stored data.
For example, a data store may be viewed as a Map of keys to values,
a Set of keys, or a Collection of values. String values, for
example, may be used with the built-in binding to the String class,
or with a custom binding to another class that represents the
string values differently.
</p>
<p>
It is sometimes desirable to use a Java class that encapsulates
both a data key and a data value. For example, a Part object might
contain both the part number (key) and the part name (value). Using
the DB Java Collections API this type of object is called an
"entity". An entity binding is used to translate between the Java
object and the stored data key and value. Entity bindings may be
used with all Collection types.
</p>
<p>
Please be aware that the provided DB Java Collections API collection classes
do not conform completely to the interface contracts
defined in the <code class="literal">java.util</code> package. For example, all
iterators must be explicitly closed and the <code class="methodname">size()</code>
method is not available. The differences between the DB Java Collections API
collections and the standard Java collections are
documented in
<a class="xref" href="UsingStoredCollections.html#StoredVersusStandardCollections" title="Stored Collections Versus Standard Java Collections">
Stored Collections Versus Standard Java Collections
</a>.
</p>
</div>
<div class="navfooter">
<hr />
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="intro.html">Prev</a> </td>
<td width="20%" align="center">
<a accesskey="u" href="intro.html">Up</a>
</td>
<td width="40%" align="right"> <a accesskey="n" href="tutorialintroduction.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Chapter 1.
Introduction
</td>
<td width="20%" align="center">
<a accesskey="h" href="index.html">Home</a>
</td>
<td width="40%" align="right" valign="top"> Tutorial Introduction</td>
</tr>
</table>
</div>
</body>
</html>
|