<s>
Btrieve	B-Application
is	O
a	O
database	O
developed	O
by	O
Pervasive	O
Software	O
.	O
</s>
<s>
The	O
architecture	B-Application
of	I-Application
Btrieve	I-Application
has	O
been	O
designed	O
with	O
record	O
management	O
in	O
mind	O
.	O
</s>
<s>
This	O
means	O
that	O
Btrieve	B-Application
only	O
deals	O
with	O
the	O
underlying	O
record	O
creation	O
,	O
data	O
retrieval	O
,	O
record	O
updating	O
and	O
data	O
deletion	O
primitives	O
.	O
</s>
<s>
Together	O
with	O
the	O
MicroKernel	B-Operating_System
Database	O
Engine	O
it	O
uses	O
ISAM	B-Application
,	O
Indexed	B-Application
Sequential	I-Application
Access	I-Application
Method	I-Application
,	O
as	O
its	O
underlying	O
storage	O
mechanism	O
.	O
</s>
<s>
Btrieve	B-Application
is	O
essentially	O
a	O
database	O
that	O
uses	O
keys	B-Application
and	O
indexes	B-Data_Structure
to	O
organise	O
data	O
.	O
</s>
<s>
However	O
,	O
the	O
file	B-Operating_System
structure	O
itself	O
is	O
largely	O
built	O
around	O
smaller	O
units	O
of	O
data	O
,	O
called	O
"	O
pages	O
"	O
in	O
Btrieve	B-Application
.	O
</s>
<s>
Though	O
the	O
structure	O
has	O
changed	O
over	O
the	O
various	O
versions	O
of	O
Btrieve	B-Application
,	O
the	O
file	B-Operating_System
structure	O
still	O
revolves	O
around	O
a	O
File	B-Operating_System
Control	O
Record	O
(	O
FCR	O
)	O
—	O
which	O
defines	O
the	O
configuration	O
of	O
pages	O
—	O
and	O
pages	O
in	O
the	O
Btrieve	B-Application
file	B-Operating_System
that	O
contain	O
data	O
.	O
</s>
<s>
Historically	O
,	O
Btrieve	B-Application
used	O
"	O
physical	O
pages	O
"	O
,	O
or	O
pages	O
that	O
were	O
located	O
at	O
fixed	O
positions	O
in	O
the	O
file	B-Operating_System
.	O
</s>
<s>
Beginning	O
with	O
version	O
6.0	O
"	O
logical	O
pages	O
"	O
started	O
to	O
be	O
used	O
,	O
which	O
were	O
mapped	O
to	O
page	O
allocation	O
tables	O
(	O
PATs	O
)	O
—	O
this	O
allowed	O
Btrieve	B-Application
to	O
change	O
their	O
record	O
update	O
technique	O
from	O
what	O
was	O
later	O
known	O
as	O
"	O
pre-image	O
paging	O
"	O
to	O
a	O
technique	O
called	O
"	O
shadow-paging	O
"	O
.	O
</s>
<s>
Btrieve	B-Application
is	O
committed	O
to	O
backward	B-General_Concept
compatibility	I-General_Concept
,	O
as	O
versions	O
of	O
Btrieve	B-Application
until	O
version	O
6.15	O
use	O
a	O
standard	O
file	B-Operating_System
format	O
and	O
,	O
until	O
Btrieve	B-Application
6.0	O
was	O
released	O
,	O
were	O
completely	O
backwards	B-General_Concept
compatible	I-General_Concept
.	O
</s>
<s>
Btrieve	B-Application
6.0	O
introduced	O
new	O
features	O
and	O
had	O
to	O
break	O
compatibility	O
with	O
older	O
versions	O
of	O
the	O
software	O
to	O
implement	O
more	O
advanced	O
features	O
.	O
</s>
<s>
The	O
API	B-General_Concept
likewise	O
remained	O
backwards	B-General_Concept
compatible	I-General_Concept
,	O
with	O
only	O
one	O
feature	O
(	O
split	O
files	O
to	O
separate	O
media	O
)	O
being	O
dropped	O
.	O
</s>
<s>
At	O
one	O
point	O
,	O
Btrieve	B-Application
's	O
former	O
CEO	B-Application
Ron	O
Harris	O
stated	O
that	O
"	O
The	O
version	O
1.0	O
API	B-General_Concept
is	O
still	O
supported	O
in	O
version	O
6.15	O
,	O
and	O
we	O
're	O
going	O
to	O
keep	O
it	O
forever	O
!	O
</s>
<s>
Pervasive	O
initially	O
used	O
the	O
term	O
"	O
navigational	B-General_Concept
database	I-General_Concept
"	O
to	O
describe	O
Btrieve	B-Application
,	O
but	O
later	O
changed	O
this	O
to	O
"	O
transactional	O
database	O
"	O
.	O
</s>
<s>
The	O
use	O
of	O
the	O
term	O
navigational	B-General_Concept
database	I-General_Concept
was	O
unusual	O
because	O
a	O
navigational	B-General_Concept
database	I-General_Concept
uses	O
"	O
pointers	O
"	O
and	O
"	O
paths	O
"	O
to	O
navigate	O
among	O
data	B-Application
records	I-Application
,	O
and	O
these	O
pointers	O
are	O
contained	O
in	O
the	O
record	O
itself	O
;	O
ISAM	B-Application
,	O
which	O
is	O
the	O
fundamental	O
structure	O
of	O
Btrieve	B-Application
,	O
uses	O
a	O
secondary	O
index	O
table	B-Application
to	O
store	O
these	O
pointers	O
to	O
decrease	O
search	O
times	O
.	O
</s>
<s>
Starting	O
with	O
version	O
6.15	O
,	O
Pervasive	O
started	O
using	O
a	O
new	O
modular	O
method	O
of	O
separating	O
the	O
database	O
backend	O
from	O
the	O
interface	O
that	O
developers	B-Application
used	O
.	O
</s>
<s>
They	O
separated	O
the	O
core	O
database	O
operations	O
(	O
like	O
update	O
,	O
write	O
and	O
delete	O
records	B-Application
)	O
from	O
the	O
Btrieve	B-Application
and	O
Scalable	O
SQL	O
modules	O
.	O
</s>
<s>
By	O
separating	O
the	O
Micro-Kernel	O
Database	O
Engine	O
(	O
MKDE	O
)	O
from	O
the	O
other	O
functions	O
it	O
allowed	O
programmers	B-Application
to	O
use	O
several	O
methods	O
of	O
accessing	O
the	O
database	O
simultaneously	O
.	O
</s>
<s>
For	O
instance	O
,	O
an	O
application	B-Application
may	O
be	O
created	O
using	O
the	O
Btrieve	B-Application
API	B-General_Concept
and	O
another	O
application	B-Application
that	O
needs	O
to	O
access	O
the	O
same	O
data	O
may	O
use	O
a	O
totally	O
different	O
method	O
,	O
like	O
using	O
Scalable	O
SQL	O
.	O
</s>
<s>
Because	O
the	O
record	O
primitives	O
have	O
been	O
separated	O
from	O
these	O
methods	O
,	O
both	O
applications	O
can	O
use	O
the	O
MKDE	O
to	O
access	O
the	O
same	O
data	O
file	B-Operating_System
.	O
</s>
<s>
The	O
Micro-Kernel	O
Database	O
Engine	O
is	O
unrelated	O
to	O
microkernel	B-Operating_System
operating	O
system	O
kernels	O
.	O
</s>
<s>
The	O
Btrieve	B-Application
file	B-Operating_System
format	O
consists	O
entirely	O
of	O
pages	O
,	O
which	O
is	O
the	O
data	O
that	O
moves	O
between	O
memory	O
and	O
storage	O
media	O
when	O
the	O
engine	O
performs	O
an	O
I/O	B-General_Concept
operation	I-General_Concept
.	O
</s>
<s>
Versions	O
prior	O
to	O
6.0	O
merely	O
used	O
data	O
pages	O
,	O
index	O
pages	O
and	O
a	O
file	B-Operating_System
control	O
record	O
(	O
FCR	O
)	O
.	O
</s>
<s>
The	O
file	B-Operating_System
had	O
an	O
index	O
for	O
searching	O
that	O
linked	O
to	O
physical	O
pages	O
.	O
</s>
<s>
Beginning	O
with	O
version	O
6.0	O
logical	O
pages	O
started	O
to	O
be	O
used	O
,	O
which	O
are	O
pages	O
that	O
are	O
mapped	O
to	O
physical	O
pages	O
(	O
pages	O
at	O
a	O
fixed	O
location	O
in	O
the	O
file	B-Operating_System
)	O
on	O
the	O
disk	O
through	O
the	O
use	O
of	O
a	O
set	O
of	O
page	O
allocation	O
tables	O
(	O
PATs	O
)	O
.	O
</s>
<s>
The	O
file	B-Operating_System
control	O
record	O
(	O
FCR	O
)	O
contains	O
important	O
information	O
about	O
Btrieve	B-Application
database	O
files	O
.	O
</s>
<s>
It	O
holds	O
the	O
page	B-General_Concept
size	I-General_Concept
,	O
the	O
number	O
of	O
pages	O
in	O
current	O
use	O
,	O
the	O
number	O
of	O
keys	B-Application
that	O
can	O
index	O
the	O
file	B-Operating_System
,	O
the	O
number	O
of	O
records	B-Application
in	O
the	O
file	B-Operating_System
and	O
other	O
details	O
.	O
</s>
<s>
Each	O
time	O
an	O
operation	O
is	O
done	O
on	O
a	O
file	B-Operating_System
the	O
field	O
is	O
incremented	O
.	O
</s>
<s>
The	O
page	B-General_Concept
size	I-General_Concept
is	O
now	O
moved	O
within	O
the	O
FCR	O
and	O
is	O
not	O
a	O
regular	O
32-bit	O
field	O
.	O
</s>
<s>
Since	O
version	O
8	O
you	O
have	O
to	O
calculate	O
the	O
page	B-General_Concept
size	I-General_Concept
by	O
taking	O
the	O
32-bit	O
field	O
at	O
offset	O
0x2A	O
and	O
multiply	O
with	O
256	O
.	O
</s>
<s>
A	O
page	O
allocation	O
table	B-Application
(	O
PAT	O
)	O
maps	O
the	O
logical	O
pages	O
to	O
the	O
physical	O
pages	O
.	O
</s>
<s>
The	O
amount	O
of	O
logical	O
records	B-Application
that	O
can	O
be	O
stored	O
in	O
the	O
PAT	O
is	O
determined	O
by	O
its	O
page	B-General_Concept
size	I-General_Concept
.	O
</s>
<s>
Until	O
version	O
6.0	O
,	O
pre-image	O
paging	O
was	O
used	O
when	O
performing	O
updates	O
to	O
records	B-Application
.	O
</s>
<s>
It	O
involved	O
the	O
creation	O
of	O
a	O
new	O
"	O
pre-image	O
file	B-Operating_System
"	O
before	O
the	O
changes	O
were	O
made	O
,	O
and	O
then	O
the	O
pages	O
from	O
the	O
original	O
data	O
file	B-Operating_System
were	O
copied	O
into	O
this	O
new	O
pre-image	O
file	B-Operating_System
temporarily	O
.	O
</s>
<s>
Then	O
the	O
system	O
would	O
make	O
the	O
changes	O
to	O
the	O
original	O
file	B-Operating_System
.	O
</s>
<s>
Should	O
the	O
update	O
be	O
interrupted	O
and	O
only	O
half	O
the	O
data	O
written	O
to	O
the	O
page	O
,	O
then	O
the	O
page	O
would	O
just	O
be	O
rolled	O
back	O
by	O
the	O
engine	O
by	O
copying	O
the	O
page	O
from	O
the	O
pre-image	O
file	B-Operating_System
back	O
into	O
the	O
corrupted	O
page	O
in	O
the	O
original	O
database	O
file	B-Operating_System
,	O
then	O
the	O
temporary	O
pre-image	O
file	B-Operating_System
would	O
be	O
deleted	O
.	O
</s>
<s>
Instead	O
of	O
copying	O
the	O
page	O
into	O
a	O
temporary	O
file	B-Operating_System
,	O
the	O
next	O
spare	O
physical	O
location	O
in	O
the	O
database	O
file	B-Operating_System
was	O
found	O
and	O
the	O
page	O
was	O
written	O
to	O
this	O
location	O
.	O
</s>
<s>
This	O
page	O
is	O
called	O
a	O
shadow	O
page	O
because	O
it	O
still	O
has	O
not	O
had	O
its	O
location	O
written	O
to	O
the	O
file	B-Operating_System
's	O
PAT	O
.	O
</s>
<s>
Once	O
the	O
update	O
to	O
the	O
shadow	O
page	O
completed	O
,	O
the	O
PAT	O
was	O
updated	O
and	O
the	O
entry	O
recorded	O
in	O
the	O
PAT	O
of	O
the	O
next	O
available	O
and	O
current	O
physical	O
page	O
in	O
the	O
file	B-Operating_System
.	O
</s>
<s>
The	O
change-over	O
from	O
pre-image	O
paging	O
to	O
shadow-paging	O
caused	O
radical	O
file	B-Operating_System
format	O
changes	O
that	O
broke	O
compatibility	O
between	O
previous	O
versions	O
of	O
Btrieve	B-Application
and	O
version	O
6.x	O
of	O
the	O
product	O
.	O
</s>
<s>
Alternate	O
Collating	O
Sequence	O
(	O
ACS	O
)	O
pages	O
are	O
pages	O
that	O
allow	O
records	B-Application
to	O
be	O
sorted	O
in	O
a	O
different	O
order	O
.	O
</s>
<s>
In	O
common	O
usage	O
,	O
this	O
is	O
called	O
alphabetisation	O
,	O
though	O
collation	O
is	O
not	O
limited	O
to	O
ordering	O
letters	O
of	O
the	O
alphabet	B-Application
.	O
</s>
<s>
Prior	O
to	O
version	O
6.0	O
only	O
one	O
ACS	O
was	O
able	O
to	O
be	O
stored	O
in	O
the	O
file	B-Operating_System
,	O
however	O
after	O
6.0	O
was	O
released	O
more	O
than	O
one	O
ACS	O
page	O
could	O
be	O
associated	O
with	O
a	O
file	B-Operating_System
at	O
any	O
one	O
time	O
.	O
</s>
<s>
In	O
Btrieve	B-Application
,	O
each	O
page	O
is	O
fixed	O
but	O
a	O
record	O
can	O
be	O
larger	O
than	O
the	O
page	B-General_Concept
size	I-General_Concept
.	O
</s>
<s>
This	O
means	O
that	O
records	B-Application
often	O
need	O
to	O
be	O
fragmented	O
and	O
spread	O
over	O
many	O
different	O
pages	O
.	O
</s>
<s>
With	O
very	O
large	O
records	B-Application
this	O
can	O
mean	O
that	O
many	O
hundreds	O
of	O
pages	O
may	O
need	O
to	O
be	O
used	O
in	O
order	O
to	O
store	O
the	O
record	O
.	O
</s>
<s>
A	O
linked	O
list	O
approach	O
would	O
be	O
able	O
to	O
allow	O
for	O
this	O
fragmentation	O
,	O
but	O
the	O
Btrieve	B-Application
engine	O
would	O
have	O
a	O
hard	O
time	O
reading	O
through	O
sequential	O
records	B-Application
.	O
</s>
<s>
Therefore	O
,	O
starting	O
with	O
version	O
6.1	O
,	O
a	O
table	B-Application
is	O
used	O
in	O
the	O
file	B-Operating_System
that	O
stores	O
pointers	O
to	O
each	O
of	O
the	O
pages	O
that	O
make	O
up	O
the	O
data	B-Application
record	I-Application
.	O
</s>
<s>
This	O
table	B-Application
is	O
called	O
a	O
variable-tail	O
allocation	O
table	B-Application
(	O
VAT	O
)	O
.	O
</s>
<s>
Btrieve	B-Application
uses	O
a	O
b-tree	B-Architecture
format	O
to	O
store	O
record	B-Data_Structure
indexes	I-Data_Structure
on	O
particular	O
table	B-Application
columns	B-Application
.	O
</s>
<s>
The	O
index	O
maps	O
each	O
set	O
of	O
indexed	O
column	O
values	O
to	O
the	O
set	O
of	O
unique	O
identifiers	O
for	O
the	O
rows	B-Application
that	O
have	O
those	O
column	O
values	O
,	O
which	O
provides	O
a	O
quick	O
way	O
to	O
find	O
the	O
rows	B-Application
within	O
a	O
table	B-Application
using	O
the	O
indexed	O
column	O
.	O
</s>
<s>
B-trees	B-Architecture
are	O
tree	B-Application
data	I-Application
structures	I-Application
and	O
are	O
very	O
efficient	O
as	O
a	O
mechanism	O
for	O
fast	O
data	O
retrieval	O
.	O
</s>
<s>
The	O
drawback	O
of	O
a	O
btree	B-Architecture
is	O
that	O
data	O
must	O
be	O
constantly	O
balanced	O
when	O
it	O
is	O
inserted	O
into	O
the	O
tree	O
,	O
therefore	O
Btrieve	B-Application
only	O
stores	O
the	O
record	O
index	O
as	O
btree	B-Architecture
to	O
reduce	O
the	O
amount	O
of	O
time	O
it	O
takes	O
to	O
insert	O
and	O
update	O
records	B-Application
.	O
</s>
<s>
A	O
separate	O
b-tree	B-Architecture
is	O
kept	O
for	O
each	O
index	O
in	O
the	O
system	O
,	O
and	O
the	O
root	B-Application
node	I-Application
information	O
is	O
kept	O
in	O
the	O
FCR	O
.	O
</s>
<s>
In	O
Btrieve	B-Application
6.x	O
a	O
new	O
index	O
can	O
be	O
created	O
at	O
file	B-Operating_System
creation	O
time	O
,	O
or	O
added	O
and	O
dropped	O
after	O
the	O
file	B-Operating_System
is	O
created	O
.	O
</s>
<s>
Before	O
Btrieve	B-Application
6.0	O
existing	O
key	O
indexes	B-Data_Structure
could	O
not	O
be	O
removed	O
,	O
though	O
supplemental	O
indexes	B-Data_Structure
could	O
be	O
created	O
and	O
dropped	O
as	O
needed	O
.	O
</s>
<s>
Btrieve	B-Application
allows	O
for	O
duplicate	O
key	O
values	O
in	O
an	O
index	O
.	O
</s>
<s>
Btrieve	B-Application
handles	O
duplicate	O
keys	B-Application
using	O
either	O
a	O
linked	O
duplicate	O
method	O
,	O
or	O
by	O
using	O
a	O
repeating	O
duplicate	O
method	O
(	O
this	O
terminology	O
started	O
being	O
used	O
when	O
version	O
6.0	O
was	O
released	O
)	O
.	O
</s>
<s>
The	O
linked	O
duplicate	O
method	O
used	O
a	O
pair	O
of	O
record	O
pointers	O
in	O
the	O
index	O
page	O
itself	O
to	O
point	O
to	O
the	O
head	O
and	O
tail	O
of	O
a	O
doubly	B-Data_Structure
linked	I-Data_Structure
list	I-Data_Structure
of	O
duplicate	O
keys	B-Application
.	O
</s>
<s>
This	O
meant	O
that	O
the	O
order	O
of	O
the	O
duplicate	O
keys	B-Application
in	O
the	O
list	O
was	O
in	O
the	O
order	O
they	O
were	O
entered	O
.	O
</s>
<s>
The	O
duplicate	O
key	O
method	O
did	O
not	O
use	O
a	O
linked	O
list	O
,	O
but	O
rather	O
made	O
all	O
the	O
keys	B-Application
unique	O
by	O
creating	O
a	O
new	O
index	O
key	O
and	O
appending	O
the	O
address	O
of	O
the	O
record	O
pointer	O
to	O
the	O
end	O
of	O
the	O
key	O
.	O
</s>
<s>
When	O
Btrieve	B-Application
needed	O
to	O
do	O
file	B-Operating_System
sharing	O
to	O
gain	O
access	O
to	O
records	B-Application
,	O
two	O
different	O
types	O
of	O
file	B-Operating_System
sharing	O
modes	O
could	O
be	O
used	O
:	O
Single	O
Engine	O
File	B-Operating_System
Sharing	O
(	O
SEFS	O
)	O
mode	O
,	O
and	O
Multi	O
Engine	O
File	B-Operating_System
Sharing	O
(	O
MEFS	O
)	O
mode	O
.	O
</s>
<s>
Btrieve	B-Application
was	O
able	O
to	O
handle	O
concurrent	B-Operating_System
transactions	I-Operating_System
in	O
the	O
6.x	O
series	O
.	O
</s>
<s>
Before	O
Btrieve	B-Application
6.0	O
the	O
engine	O
could	O
only	O
do	O
file	B-Operating_System
level	O
locking	O
or	O
exclusive	O
locking	O
;	O
from	O
6.0	O
onward	O
,	O
records	B-Application
could	O
be	O
locked	O
individually	O
.	O
</s>
<s>
The	O
advantages	O
were	O
obvious	O
:	O
more	O
than	O
one	O
client	O
could	O
access	O
the	O
file	B-Operating_System
at	O
the	O
same	O
time	O
,	O
so	O
long	O
as	O
they	O
were	O
n't	O
trying	O
to	O
access	O
the	O
same	O
record	O
,	O
leading	O
to	O
performance	O
increases	O
.	O
</s>
<s>
Additionally	O
,	O
other	O
clients	O
could	O
read	O
the	O
locked	O
pages	O
,	O
and	O
would	O
not	O
see	O
any	O
changes	O
to	O
a	O
file	B-Operating_System
involved	O
in	O
a	O
write	O
transaction	O
by	O
another	O
process	O
that	O
had	O
locked	O
the	O
record	O
.	O
</s>
<s>
If	O
a	O
client	O
started	O
a	O
concurrent	O
transaction	O
and	O
then	O
tried	O
to	O
perform	O
a	O
write	O
operation	O
to	O
a	O
record	O
,	O
the	O
Btrieve	B-Application
engine	O
would	O
return	O
a	O
status	O
code	O
85	O
that	O
indicated	O
that	O
the	O
file	B-Operating_System
was	O
locked	O
—	O
even	O
though	O
a	O
concurrent	O
lock	O
was	O
being	O
used	O
.	O
</s>
<s>
Starting	O
with	O
version	O
6.15	O
of	O
Btrieve	B-Application
,	O
a	O
new	O
type	O
of	O
database	B-General_Concept
transaction	I-General_Concept
was	O
introduced	O
called	O
a	O
system	O
transaction	O
,	O
which	O
was	O
separated	O
from	O
user	O
transactions	O
.	O
</s>
<s>
User	O
transactions	O
are	O
exclusive	O
and	O
concurrent	B-Operating_System
transactions	I-Operating_System
while	O
system	O
transactions	O
are	O
a	O
bundle	O
of	O
non-transactional	O
operations	O
and/or	O
user	O
transactions	O
.	O
</s>
