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>Developing a DB Collections Application</title> 7 <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.62.4" /> 9 <link rel="home" href="index.html" title="Berkeley DB Collections Tutorial" /> 10 <link rel="up" href="intro.html" title="Chapter��1.�� Introduction " /> 11 <link rel="previous" href="intro.html" title="Chapter��1.�� Introduction " /> 12 <link rel="next" href="tutorialintroduction.html" title="Tutorial Introduction" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">Developing a DB Collections Application</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="intro.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��1.�� 23 Introduction 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="tutorialintroduction.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="developing"></a>Developing a DB Collections Application</h2> 35 </div> 36 </div> 37 <div></div> 38 </div> 39 <p> 40 There are several important choices to make when developing an 41 application using the DB Java Collections API. 42 </p> 43 <div class="orderedlist"> 44 <ol type="1"> 45 <li> 46 <p> 47 Choose the Berkeley DB Environment 48 </p> 49 <p> 50 Depending on your application's concurrency and transactional 51 requirements, you may choose one of the three Berkeley DB 52 Environments: Data Store, Concurrent Data Store, or 53 Transactional Data Store. For details on creating and 54 configuring the environment, see the 55 <i class="citetitle">Berkeley DB Programmer's Reference Guide</i> 56 </p> 57 </li> 58 <li> 59 <p> 60 Choose the Berkeley DB Access Method 61 </p> 62 <p> 63 For each Berkeley DB datastore, you may choose from any of the 64 four Berkeley DB access methods ��� BTREE, HASH, RECNO, or 65 QUEUE 66 <span class="html"> 67 (<a href="../../java/com/sleepycat/db/DatabaseType.html#BTREE" target="_top">DatabaseType.BTREE</a>, 68 <a href="../../java/com/sleepycat/db/DatabaseType.html#HASH" target="_top">DatabaseType.HASH</a>, 69 <a href="../../java/com/sleepycat/db/DatabaseType.html#RECNO" target="_top">DatabaseType.RECNO</a>, 70 or 71 <a href="../../java/com/sleepycat/db/DatabaseType.html#QUEUE" target="_top">DatabaseType.QUEUE</a>.) 72 </span> 73 ��� and a number of other database options. Your choice 74 depends on several factors such as whether you need ordered 75 keys, unique keys, record number access, and so forth. For more 76 information on access methods, see the 77 <i class="citetitle">Berkeley DB Programmer's Reference Guide</i>. 78 </p> 79 </li> 80 <li> 81 <p> 82 Choose the Format for Keys and Values 83 </p> 84 <p> 85 For each database you may choose a binding format for the keys 86 and values. For example, the tuple format is useful for keys 87 because it has a deterministic sort order. The serial format is 88 useful for values if you want to store arbitrary Java objects. In 89 some cases a custom format may be appropriate. For details on 90 choosing a binding format see 91 <a href="collectionOverview.html#UsingDataBindings"> 92 Using Data Bindings 93 </a>. 94 </p> 95 </li> 96 <li> 97 <p> 98 Choose the Binding for Keys and Values 99 </p> 100 <p> 101 With the serial data format you do not have to create a binding 102 for each Java class that is stored since Java serialization is 103 used. But for other formats a binding must be defined that 104 translates between stored byte arrays and Java objects. For details 105 see 106 <a href="collectionOverview.html#UsingDataBindings"> 107 Using Data Bindings 108 </a>. 109 </p> 110 </li> 111 <li> 112 <p> 113 Choose Secondary Indices 114 </p> 115 <p> 116 Any database that has unique keys may have any number of 117 secondary indices. A secondary index has keys that are derived from 118 data values in the primary database. This allows lookup and 119 iteration of objects in the database by its index keys. 120 121 122 123 For each index you must define how the index keys are derived from the data 124 values using a 125 126 <span> 127 <a href="../../java/com/sleepycat/db/SecondaryKeyCreator.html" target="_top">SecondaryKeyCreator</a>. 128 </span> 129 For details see the 130 131 132 <span> 133 <a href="../../java/com/sleepycat/db/SecondaryDatabase.html" target="_top">SecondaryDatabase</a>, 134 </span> 135 136 137 <a href="../../java/com/sleepycat/db/SecondaryConfig.html" target="_top">SecondaryConfig</a> 138 139 and 140 141 <a href="../../java/com/sleepycat/db/SecondaryKeyCreator.html" target="_top">SecondaryKeyCreator</a> 142 143 classes. 144 </p> 145 </li> 146 <li> 147 <p> 148 Choose the Collection Interface for each Database 149 </p> 150 <p> 151 The standard Java Collection interfaces are used for accessing 152 databases and secondary indices. The Map and Set interfaces may be 153 used for any type of database. The Iterator interface is used 154 through the Set interfaces. For more information on the collection 155 interfaces see 156 <a href="UsingStoredCollections.html"> 157 Using Stored Collections 158 </a>. 159 </p> 160 </li> 161 </ol> 162 </div> 163 <p> 164 Any number of bindings and collections may be created for the 165 same database. This allows multiple views of the same stored data. 166 For example, a data store may be viewed as a Map of keys to values, 167 a Set of keys, or a Collection of values. String values, for 168 example, may be used with the built-in binding to the String class, 169 or with a custom binding to another class that represents the 170 string values differently. 171 </p> 172 <p> 173 It is sometimes desirable to use a Java class that encapsulates 174 both a data key and a data value. For example, a Part object might 175 contain both the part number (key) and the part name (value). Using 176 the DB Java Collections API this type of object is called an 177 "entity". An entity binding is used to translate between the Java 178 object and the stored data key and value. Entity bindings may be 179 used with all Collection types. 180 </p> 181 <p> 182 Please be aware that the provided DB Java Collections API collection classes 183 do not conform completely to the interface contracts 184 defined in the <tt class="literal">java.util</tt> package. For example, all 185 iterators must be explicitly closed and the <tt class="methodname">size()</tt> 186 method is not available. The differences between the DB Java Collections API 187 collections and the standard Java collections are 188 documented in 189 <a href="UsingStoredCollections.html#StoredVersusStandardCollections"> 190 Stored Collections Versus Standard Java Collections 191 </a>. 192 </p> 193 </div> 194 <div class="navfooter"> 195 <hr /> 196 <table width="100%" summary="Navigation footer"> 197 <tr> 198 <td width="40%" align="left"><a accesskey="p" href="intro.html">Prev</a>��</td> 199 <td width="20%" align="center"> 200 <a accesskey="u" href="intro.html">Up</a> 201 </td> 202 <td width="40%" align="right">��<a accesskey="n" href="tutorialintroduction.html">Next</a></td> 203 </tr> 204 <tr> 205 <td width="40%" align="left" valign="top">Chapter��1.�� 206 Introduction 207 ��</td> 208 <td width="20%" align="center"> 209 <a accesskey="h" href="index.html">Home</a> 210 </td> 211 <td width="40%" align="right" valign="top">��Tutorial Introduction</td> 212 </tr> 213 </table> 214 </div> 215 </body> 216</html> 217