# dbXML Core Administration version 1.0

Staken
Kimbro
The dbXML Project
2001
The dbXML Group L.L.C.
$Id: AdministratorsGuide.xml,v 1.13 2001/09/12 18:47:32 kstaken Exp $

This documentation is a work in progress. Links to the most current version can be found at http://www.dbxml.org/docs/

## Database Administration

Database administration of dbXML is accomplished from the command line using the `dbxmladmin` command. This command allows you to view and alter the database configuration on the fly on a running system. A complete list of available commands and more detail about each command can be found in the Command Line Tools Reference Guide.

### Managing Collections

#### Adding a Collection

Adds a collection named products under the collection /db/data.

    dbxmladmin add_collection -c /db/data -n products

#### Deleting a Collection

Deletes the collection named products from the collection /db/data.

    dbxmladmin delete_collection -c /db/data/products

#### Listing the Collections

This will display a list of all child collections under the collection /db/data

    dbxmladmin list_collections -c /db/data

### Managing Indexes

The dbXML indexing system allows you to define indexes to speed performance on commonly used XPath queries. If no indexes are defined you can still execute queries but performance will suffer because the query engine will need to scan the entire collection to create the result node-set.

Indexes can be added using the `dbxmladmin` command.

#### Adding an Index

Using this simple XML file you might want to index the product_id element because searches for products by product_id are common.

    <?xml version="1.0"?>
    <product>
       <product_id>120320</product_id>
       <description>Glazed Ham</description>
    </product>

This can be accomplished by running the following command. This will create an index named idindex on all product_id elements in the collection /db/data/catalog.

    dbxmladmin add_indexer -c /db/data/catalog -n idindex -p product_id

Once this is done the query engine will now use this index to help resolve XPath queries that involve restriction on the value of the product_id element.

The -p parameter to the command specifies the pattern to use in the index. These patterns are used by the Indexing system to determine best-fit and match-based Indexers for queries and index updating. The pattern used MUST resemble the following scheme.

    Pattern     Description
    =========== ====================================================
    elem        The value of the named element
    elem@attr   The value of the attribute for the named element
    *           The value for all elements
    *@attr      The value of the named attribute for all elements
    elem@*      The value of all attributes for the named element
    *@*         The value of all attributes for all elements

Note: In order to index a namespace other than the default namespace, you must prepend your pattern components with a URI placed in square brackets. Example:

    [http://www.world.org/People]person
    *@[http://www.world.org/People]id
    [http://www.world.org/People]person@[http://www.world.org/People]id

Do not include a prefix in these patterns, as the indexing system, like most Namespace processing applications, processes namespaced elements and attributes independently of the prefix that is used.

#### Indexing both Elements and Attributes

Because the patterns recognize either an element or an attribute, and not both, in order to index all element and attribute values in a collection, you'd have to create two index entries. The * pattern will index all elements and the *@* pattern will index all attributes of all elements.

    dbxmladmin add_collection_indexer -c /db/data/catalog -n idindex -p '*'
    dbxmladmin add_collection_indexer -c /db/data/catalog -n idindex -p '*@*'

Excessive use of wildcard indexes can adversely affect the performance of the indexing system. Best practice would be to use specific element or attribute indexes whenever possible, and only define wildcard indexes when it is absolutely necessary.

## Server Administration

### Starting the Server

The server must be started from within the dbXML-Core directory. A future revision of the server will fix this limitation.

#### Starting the Server on UNIX

                   cd dbXML-Core
                   ./start

#### Starting the Server on Windows

                   cd dbXML-Core
                   startup

### Stopping the Server

The dbXML server can be easily shutdown from the command line. You must provide the name of the server instance to shutdown.

#### Stopping the Server

This example assumes that the dbXML-Core/bin directory is in your path.

                   dbxmladmin shutdown -c /db

### Backing up Your Data

Currently backing up dbXML consists of simply shutting down the server and copying the entire contents of the dbXML-Core/db directory to the backup media. A more robust online backup operation will need to be developed in the future

#### Backing up the server

This example assumes that the dbXML-Core/bin directory is in your path.

                   cd dbXML-Core
                   dbxmladmin shutdown
                   cp -pr db /backup/db
                   ./start

#### Restoring the Data

Restoring the data is simply removing the current database and reversing the backup process. This example assumes that the dbXML-Core/bin directory is in your path.

                   cd dbXML-Core
                   dbxmladmin shutdown
                   rm -rf db
                   cp -pr /backup/db db
                   ./start