developing.html   [plain text]


<?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.62.4" />
    <link rel="home" href="index.html" title="Berkeley DB Collections Tutorial" />
    <link rel="up" href="intro.html" title="Chapter 1. &#10;        Introduction&#10;    " />
    <link rel="previous" href="intro.html" title="Chapter 1. &#10;        Introduction&#10;    " />
    <link rel="next" href="tutorialintroduction.html" title="Tutorial Introduction" />
  </head>
  <body>
    <div class="navheader">
      <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></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 
                <i class="citetitle">Berkeley DB Programmer's Reference Guide</i>
            </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 href="../../java/com/sleepycat/db/DatabaseType.html#BTREE" target="_top">DatabaseType.BTREE</a>,
                    <a href="../../java/com/sleepycat/db/DatabaseType.html#HASH" target="_top">DatabaseType.HASH</a>,
                    <a href="../../java/com/sleepycat/db/DatabaseType.html#RECNO" target="_top">DatabaseType.RECNO</a>,
                    or
                    <a 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
                <i class="citetitle">Berkeley DB Programmer's Reference Guide</i>.
            </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 href="collectionOverview.html#UsingDataBindings">
        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 href="collectionOverview.html#UsingDataBindings">
        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 href="../../java/com/sleepycat/db/SecondaryKeyCreator.html" target="_top">SecondaryKeyCreator</a>.
                </span>
                For details see the

                
                <span>
                    <a href="../../java/com/sleepycat/db/SecondaryDatabase.html" target="_top">SecondaryDatabase</a>,
                </span>

                
                <a href="../../java/com/sleepycat/db/SecondaryConfig.html" target="_top">SecondaryConfig</a>
                
                and
                
                <a 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 href="UsingStoredCollections.html">
        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 <tt class="literal">java.util</tt> package. For example, all
        iterators must be explicitly closed and the <tt class="methodname">size()</tt>
        method is not available. The differences between the DB Java Collections API
        collections and the standard Java collections are
        documented in 
        <a href="UsingStoredCollections.html#StoredVersusStandardCollections">
            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>