<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>mcetin</title>
    <link rel="alternate" type="text/html" href="https://blogs.perl.org/users/mcetin/" />
    <link rel="self" type="application/atom+xml" href="https://blogs.perl.org/users/mcetin/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/mcetin//4881</id>
    <updated>2026-09-02T08:38:58Z</updated>
    <subtitle>A blog about the Perl programming language</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>AmberDB - An Embedded NoSQL Database Engine for Perl</title>
    <link rel="alternate" type="text/html" href="https://blogs.perl.org/users/mcetin/2026/08/amberdb---an-embedded-nosql-database-engine-for-perl.html" />
    <id>tag:blogs.perl.org,2026:/users/mcetin//4881.12107</id>

    <published>2026-08-31T22:53:48Z</published>
    <updated>2026-09-02T08:38:58Z</updated>

    <summary>AmberDB is an embedded, schema-driven NoSQL database engine for Perl, designed for applications that need structured records, fast indexed queries, full-text search, transactions, and a simple deployment model. It is built on top of Berkeley DB through DB_File, but AmberDB...</summary>
    <author>
        <name>Maruf Çetin</name>
        
    </author>
    
        <category term="Database" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="NoSQL" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Pure Perl" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="amberdb" label="AmberDB" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="database" label="Database" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="db_file" label="DB_File" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="fulltextsearch" label="Full-Text Search" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="nosql" label="NoSQL" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perl" label="Perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="schema" label="Schema" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="transactions" label="Transactions" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="https://blogs.perl.org/users/mcetin/">
        <![CDATA[<p><b>AmberDB</b> is an embedded, schema-driven NoSQL database engine
for Perl, designed for applications that need structured records,
fast indexed queries, full-text search, transactions, and a simple
deployment model.</p>
<p>It is built on top of Berkeley DB through <font face="Liberation Mono, monospace">DB_File</font>,
but AmberDB provides a much higher-level database API rather than
exposing the underlying key-value store directly.</p>
<h2 class="western">Why AmberDB?</h2>
<p>AmberDB brings several capabilities together in a single Perl
database engine:</p>
<ul><li>a simple Perl-native CRUD API</li><li>schemaless and schema-driven data structures</li><li>indexed matching and filtering</li><li>full-text search</li><li>sorting and faceted queries</li><li>relational and repeated data blocks</li><li>multi-table transactions</li><li>concurrency control</li><li>high-throughput batch operations</li><li>portable database archives and restore tools</li></ul>
<p>The result is a database where operations that often require
additional layers, services, or complex query logic can be handled
directly by the database itself.</p>
<p>For example, a Perl application can insert, read, modify, search,
and delete records using a small and consistent API, while the schema
controls validation and indexing behind the scenes.</p>
<p>AmberDB is built around a straightforward principle:</p>
<p><b>The database should make common application data operations
simple, fast, and predictable.</b></p>
<h2 class="western">A database operation can be this simple</h2>
<p>After creating an AmberDB instance, inserting a record is
straightforward:</p>
<pre class="western" style="background: #e1e1e1; margin-bottom: 0.5cm">use AmberDB;<br />
<br />
my $db = AmberDB-&gt;new(
    cfg  =&gt; { user =&gt; 'admin', language =&gt; 'en' },
    path =&gt; { dbase_dir =&gt; './dbstore' }
);<br />
my @product = (
    0,
    "Wireless Headphones",
    149.99,
    "Electronics",
    1
);<br />
my $id = $db-&gt;insert_id(
    "products",   # table
    @product      # record
);</pre><p>
Reading the record back:</p>
<pre class="western" style="background: #e1e1e1; margin-bottom: 0.5cm">my @product = $db-&gt;read_id("products", $id);</pre><p>
Modify it:</p>
<pre class="western" style="background: #e1e1e1; margin-bottom: 0.5cm">$product[2] = 129.99;<br />
$db-&gt;modify_id(
    "products",
    @product
);</pre><p>
And delete it:</p>
<pre class="western" style="background: #e1e1e1; margin-bottom: 0.5cm">$db-&gt;delete_id("products", $id);</pre><p>
That's the basic CRUD API.</p>
<p>There is no SQL query to construct, no ORM required, and no
separate query language between the Perl application and the
database.</p>
<p>For many applications, database access can therefore look very
similar to ordinary Perl data manipulation.</p>
<h2 class="western">Using schemas for advanced applications</h2>
<p>AmberDB works even without a schema definition. However, schemas
can significantly increase the engine's capabilities by defining the
structure of a table and how its data should be indexed and searched.</p>
<p>There is no separate indexing system to configure. Once the schema
is defined, AmberDB automatically builds and maintains the required
indexes.</p>
<p>For example:</p>
<pre class="western" style="background: #e1e1e1; margin-bottom: 0.5cm">{
    name         =&gt; "Table Name",
    record_index =&gt; 1,              # readall
    search_block =&gt; [2,4,5,8],      # blocks to search
    match_block  =&gt; [1,3,8],        # blocks to match
    sort_block   =&gt; [1,3,5,7,10],   # blocks to sort
}</pre><p>
AmberDB automatically creates inverted indexes for the blocks defined
by the table schema. These indexes provide very fast search and
filtering operations, even with large datasets.</p>
<h2 class="western">Indexed reads instead of scanning records</h2><p>AmberDB is designed to perform much of the work when data is
inserted or indexes are rebuilt, rather than repeatedly doing
expensive work during queries.</p><p>This makes operations such as filtering, sorting, pagination, and
searching large datasets possible without requiring an external
search server.</p>
<p>For example:</p>
<pre class="western" style="background: #e1e1e1; margin-bottom: 0.5cm">my ($total, @products) = $db-&gt;search_table(
    "products",
    "wireless headphones",
    start =&gt; 0,
    limit =&gt; 20
);</pre><p>
The same database can therefore provide both ordinary record access
and full-text search.</p>
<h2 class="western">AmberDB does not join</h2>
<p>A record can contain or be linked to relational data from other
tables. For example, an order record might contain customer
information, payment information, shipping and delivery information,
various dates, and a collection of order items containing the product
number, name, price at the time of sale, applied discount, and other
information.</p>
<p>AmberDB processes these structures as part of the record model and
uses custom indexes to make them easy to query.</p>
<p>This can be useful when the application's natural model is
something like:</p>
<pre class="western" style="background: #e1e1e1; margin-bottom: 0.5cm">Order<br />
 ├── Customer
 ├── Address
 ├── Dates [ as array ]
 ├── Payment
 └── Items
      ├── Product
      ├── Quantity
      └── Price</pre><p>
Instead of reconstructing the object from multiple tables through
joins, the application can work with the structure directly, in a way
that is much closer to Perl's own data model.</p>
<h2 class="western">ACID Transactions</h2>
<p>Although AmberDB is a performance-oriented NoSQL engine, it
provides multi-table ACID transactions using an undo journal and
Strict Two-Phase Locking (Strict 2PL).</p>
<p>AmberDB also supports concurrent access using OS-level file
locking, making it suitable for multi-process Perl applications.</p>
<p>The <font face="Liberation Mono, monospace">transact</font> API is
simple to use, while the mechanisms behind it provide atomicity,
consistency, isolation, and durability across related operations.</p>
<pre class="western" style="background: #e1e1e1; margin-bottom: 0.5cm">$db-&gt;transact_start();<br />
# update order<br /># update customer account
# update stock
# insert payment record<br />
$db-&gt;transact_end();</pre><p>
If an error occurs, the transaction can be rolled back, including the
corresponding index changes.</p>
<p>The undo journal also provides recovery after an unexpected
process or system failure.</p>
<h2 class="western">Batch operations for large imports</h2>
<p>Transactional record operations and bulk data loading are
intentionally treated as different workloads.</p>
<p>For ETL, CSV imports, migrations, and large datasets, AmberDB
provides batch methods such as:</p>
<pre class="western" style="background: #e1e1e1; margin-bottom: 0.5cm">$db-&gt;insert_list("products", @records);
$db-&gt;modify_list("products", @records);
$db-&gt;delete_list("products", @ids);</pre><p>
For example, when you insert a list of a thousand records using
<font face="Liberation Mono, monospace">insert_list</font>, AmberDB
creates the records and their indexes as a batch operation.</p>
<p>Similarly, a large price list can be modified in a single batch
operation.</p>
<p>This makes batch methods particularly useful for imports,
migrations, synchronization jobs, and other high-volume data
operations.</p>
<h2 class="western">Portable backups</h2>
<p>AmberDB also includes native database tools for backup and
restore.</p>
<p>A database can be exported to a portable <font face="Liberation Mono, monospace">.amberdb</font>
archive containing the authoritative database state and schema.
Integrity can be verified using SHA-256, and derived indexes can be
rebuilt during restore.</p><p>This makes it possible to move or archive a complete database
without requiring a separate database server.</p><h2 class="western">Getting started</h2>
<p>AmberDB 5.22.0 is available on CPAN:</p>
<pre class="western" style="background: #e1e1e1; margin-bottom: 0.5cm">cpanm AmberDB</pre><p>
The project is released under the Artistic License 2.0.</p>
<p>The source code, documentation, and examples are available on
MetaCPAN and GitHub.</p>
<p>If you are a Perl developer working with a significant amount of
structured data, give AmberDB a try.</p>
<p><br />
<br />

</p>
<br />]]>
        
    </content>
</entry>

</feed>
