This article is part of the Advanced User's Guide. It presents some low-level details on how data is stored in the database files.
The following data types are used for specifying the storage layout:
|Type||Description||Example (native → hex integers)|
||Compressed integer (1-5 bytes), specified in Num.java|
||Number, stored as token|
||Boolean (1 byte,
||Arrays of values, introduced with the number of entries|
||Key array (
The following tables illustrate the layout of the BaseX database files. All files are suffixed with
Meta Data, Name/Path/Doc Indexes:
|1. Meta Data||1. Key/value pairs, in no particular order (
2. Empty key as finalizer
|2. Main memory indexes||1. Key/value pairs, in no particular order (
2. Empty key as finalizer
|2 a) Name Index
|1. Token set, storing all names (
2. One StatsKey instance per entry:
2.1. Content kind (
2.1.1. Number: min/max (
2.1.2. Category: number of entries (
2.2. Number of entries (
2.3. Leaf flag (
2.4. Maximum text length (
|2 b) Path Index||1. Flag for path definition (
2.1. Name reference (
2.2. Node kind (
2.3. Number of occurrences (
2.4. Number of children (
2.6. Recursive generation of child nodes (→ 2)
|2 c) Namespaces||1. Token set, storing prefixes (
2. Token set, storing URIs (
3.1. pre value (
3.2. References to prefix/URI pairs (
3.3. Number of children (
3.4. Recursive generation of child nodes (→ 3)
|2 d) Document Index||Array of integers, representing the distances between all document pre values (
tbl: Main database table, stored in blocks.
tbli: Database directory, organizing the database blocks.
Some more information on the node storage is available.
txt: Heap file for text values (document names, string values of texts, comments and processing instructions)
atv: Heap file for attribute values.
txtl: Heap file with ID lists.
txtr: Index file with references to ID lists.
The Attribute Index is contained in the files
atvr, the Token Index in
tokr. All have the same layout.
For a more detailed discussion and examples of these file formats please see Index File Structure.
Document Path Index:
Provides an index of all the document paths in the database. For databases with a large number of paths this file can be quite large so it is only generated the first time a function requesting a path lookup is run. For databases where path lookups are never used this file will not exist.
Note: On Windows/Mac systems this file is case insensitive (all paths are lower case). On UNIX-like systems this file is case sensitive. The behaviour of path look ups will vary between systems. Copying this file between system types may lead to unexpected behaviour.
This file is only created if incremental indexing (UPDINDEX) is enabled for a database. It is used to provide a quick look up of the pre value for a database node id.
Full-Text Fuzzy Index:
...may soon be reimplemented.