summaryrefslogtreecommitdiff
path: root/docs/html/xbc8.htm
blob: cb4765706be0a92dfc0a4fe8ded92bbfe2cc658f (plain)
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
<!DOCTYPE HTML PUBLIC>
<HTML>
<TITLE>Xbase DBMS Chapter 8</TITLE>
<BODY BGCOLOR=#FFFFFF>
<H2><p align="center">MDX Indices</p></H2>
<p align="center">Chapter Updated 11/28/22</p><hr>

The objective of this chapter is to provide information regarding the
basic concepts of how .MDX index files work in the Xbase environment.<br><br>

The information in this chapter has been gathered by searching the internet
and by examining the structure of known good <DX indexes.<br><br>

<h4>MDX Index File Characteristics</h4>

<li>MDX files are the same name as the corresponding DBF file with an MDX extension.
<li>MDX files are automatically opened by the library when the DBF file is opened.
<li>MDX index files (aka prod indices) contain from one to 47 tags, where each tag has it's own key characteristics.
<li>MDX indices maintain keys in either ascending or descending sort order.
<li>MDX indices support filtered keys.  For example, a filter of <b>.NOT. DELETED()</b> will keep deleted records out
of the index tag.
<li>MDX indices are automatically updated by the Xbase library after the
indices are opened.

<li>MDX indices support <em>unique</em> or <em>non unique</em> keys.<br><br>

<em>Unique</em> keys must be unique if the UniqueKeyOption is not set to XB_EMULATE_DBASE.
If the UniqueKeyOption is set to XB_EMULATE_DBASE, then the database update routines will 
add a record to the table, but not add a corresponding duplicate key to the index tag.
The UniqueKeyOption is off (don't allow duplicates) by default.
<br><br>

<em>Non-unique</em> Keys are not required to be unique, duplicate
keys are allowed if the index is created with the XB_NOT_UNIQUE
setting.  Duplicate keys are stored in record number order.<br><br>


<li>Character keys are left justified and padded on the right with spaces.
<li>Numeric keys are stored as twelve byte BCD values.
<li>Date keys are stored as eight byte double julian values.

<h4>MDX File Internals</h4>

The following information is not needed to use the library, it is just included
for general information.<br><br>

MDX files are comprised of 512 pages where multiple pages make a block.  The default 
setting is 1024 blocks, each block containing two pages.<br><br>

The first four pages contain:
<li>Bytes 0 - 543 contain general file information.
<li>Bytes 544 - 2047 is a 47 item table containing specific tag information.
<br><br>

Pages five and beyound:
<li>Bytes 2048 and beyond contain tag header blocks, interior nodes and leaf nodes.

<br><br>

<h4>Interior and Leaf Nodes</h4>

Interior Nodes and Leaf Nodes share the same structure in an NDX file with 
the exception that interior nodes have a non zero number immediately
after the rightmost key on the node.

Interior nodes point to other interior nodes or leaf nodes and leaf nodes point 
to records in a DBF file.   Interior nodes are optional nodes in an MDX file,
however if there are more than a few keys in the index there will 
certainly be one or more interior nodes in the file.  There will 
always be at least one leaf node per tag in the file.  Leaf nodes 
contain DBF record numbers which point to the location of the record 
in the DBF file.<br><br>

<br><br>

<hr>
<p><img src="xbase.jpg"><br><hr>
</BODY>
</HTML>