-
Notifications
You must be signed in to change notification settings - Fork 0
Concept Relational Records
Turkce Dokumantasyon | English Documentation
Category: Core Concepts & Architecture
Subsystem: Data Model & Inverted Indexing (AmberDB::Base&AmberDB::Index)
Entry Type: Relational Data Modeling Guide
AmberDB resolves the fragmentation and runtime JOIN performance bottlenecks of traditional relational SQL engines through its JOIN-Free Document Block Model. However, real-world data models inevitably require linking to external entities and dimensions (e.g. Products
In AmberDB, relational foreign keys are managed via three complementary high-performance mechanisms:
-
Multi-Value Delimited Foreign Keys (
match_block): Storing foreign keys as compact CSV strings ("5,12,89") that are unpacked and indexed in inverted.fldfiles for instant$O(1)$ lookups. -
Automated External Text Resolution in Search Indexing (
search_block): When configuringsearch_blockin the schema, you can specify both native text blocks and external relational blocks ([ 2, "catalog_categories", 1 ]orrdbm). During write indexing (search_add), the engine automatically checks each block: if it contains direct text, it tokenizes and indexes it; if it references an external table, AmberDB automatically opens the external table file, looks up the record by the foreign key ID, extracts the display name, and indexes those tokens into the parent's.srcfull-text search index. -
Bidirectional Dictionary & Uniqueness Index (
.unq): Automated bidirectional mapping (s:Text$\leftrightarrow$ n:ID) of textual tags, categorical labels, and uniqueness constraints (valid => "unique").
search_block Automated External Text Resolution Pipeline
[Product Record: catalog_products]
- [1] Title: "Sony WH-1000XM5" (Direct Text) ──┐
- [2] Category FK: 12 (rdbm Link) ──┼──> [AmberDB search_add Pipeline]
│ │
[External Table: catalog_categories] │ v
- ID 12 => [1] "Wireless Audio Systems" ──────────┘ Tokens Written to .src Index:
"sony", "wh", "1000xm5",
"wireless", "audio", "systems" ──> [1001]
When an entity belongs to multiple categories or tags, AmberDB avoids many-to-many bridge tables. Related foreign IDs are joined into a single delimited string:
# Record array with foreign key CSV list:
my @product = (
0, # [0] Auto-increment ID
"MacBook Pro 16", # [1] Title
"5,12,89", # [2] Category Foreign Keys (CSV)
2499.00, # [3] Price
);When match_block => [ 2 ] is configured in the schema, the engine unpacks "5,12,89" and indexes the product ID under each foreign key (5, 12, 89) inside the .fld inverted index.
# Fetch all products belonging to Category #12 in $O(1) time (Zero SQL JOINs!):
my ($total, @products) = $adb->field_fetch("catalog_products", 2 => 12);In search interfaces, users frequently search for combinations of product names, categories, and brand terms (e.g., "Sony Wireless Audio" or "Apple Laptop").
In SQL databases, this requires expensive multi-table JOIN queries. In AmberDB, the application does not need to manually concatenate text. Configuring relational blocks in search_block directs the engine to resolve external text automatically:
{
fields => [
{ id => "id", name => "Product ID", type => "num" }, # [0]
{ id => "title", name => "Product Title", type => "text" }, # [1]
{ id => "cat_id", name => "Category", type => "num", rdbm => "catalog_categories;1" }, # [2]
{ id => "price", name => "Price", type => "num" }, # [3]
],
# Search index includes both local title (1) and external category name ([2, "catalog_categories", 1]):
search_block => [ 1, [ 2, "catalog_categories", 1 ] ],
}use AmberDB;
my $adb = AmberDB->new(path => { dbase_dir => "./dbstore" });
# 1. External table contains Category #12 = "Wireless Audio Systems"
# 2. Insert standard clean record data:
my @product = (
0, # [0] Auto-increment ID
"Sony WH-1000XM5", # [1] Title (Text)
12, # [2] Category FK (Linked to catalog_categories)
399.99, # [3] Price
);
# During insert_id, AmberDB:
# - Reads title "Sony WH-1000XM5" from block 1.
# - Sees FK 12 at block 2, opens "catalog_categories", and reads "Wireless Audio Systems" from block 1.
# - Combines and tokenizes words from both sources into catalog_products_1.src.
$adb->insert_id("catalog_products", @product);
# 3. Searches matching external category terms resolve instantly without JOINs:
my ($total, @results) = $adb->search_table("catalog_products", "sony audio");
print "Found $total matching products.\n";For dynamic facets and text tags, AmberDB maintains bidirectional .unq dictionary files (${table}_${blk}.unq):
- Text
$\rightarrow$ Integer ID (s:Text$\rightarrow$ ID) - Integer ID
$\rightarrow$ Text (n:ID$\rightarrow$ Text)
This ensures that uniqueness is enforced and variable string labels are indexed as compact integer bitsets, minimizing memory and disk overhead.
- Zero Runtime JOIN Overhead: Eliminates multi-table joins at query execution time.
-
Unified Single-Pass Full-Text Search: Resolves multi-entity search terms in a single
$O(1)$ inverted index scan. - Linear Predictable Latency: Maintains sub-millisecond query responses regardless of database size.
AmberDB — High-Performance Schema-Driven NoSQL Database Engine for Perl.
Copyright 2005-2026 Maruf Cetin. Released under the Artistic License 2.0.
CPAN · GitHub Repository · Issue Tracker
- Berkeley DB (DB_File) Engine
- AmberDB Table Schema
- Global Flags
- Table Schema Flags
- Directory Structure
- File Structure (Extensions)
- Repeat Blocks
- Auto-Increment ID
- ASCII ID
- Relational Records
- Record Anatomy
- JOIN-Free Architecture
- Packed Binary Index
- Strict 2PL Locking
- Undo Journal & Rollback
- Tiered Junk Indexing
- Disjunctive Faceting
- Phonetic Accent Search
- 2-Pillar Disaster Recovery
- RAM-Disk Acceleration
- In-Memory Schema Mutation
- Simple Mode
- new
- config
- set_datadir
- insert_id
- insert_list
- modify_id
- modify_list
- delete_id
- delete_list
- read_id
- read_all
- read_list
- exist_id
- exist_list
- exist_table
- table_count
- table_keys
- table_lastid
- table_attr
- table_create
- field_fetch
- field_filter
- search_table
- facet_menu
- field_fltkeys
- field_allfltkeys
- facet_rules
- slug_read
- slug_fetch
- transact_start
- transact_end
- transact_commit
- transact_rollback
- transact_recover
- flock_open
- flock_close
- cache_setup
- cache_read
- cache_write
- cache_delete
- cache_preload
- cache_ensure
- buffer_write
- buffer_read
- buffer_delete
- recs_scan
- recs_get
- recs_put
- recs_del
- locale_uc
- locale_lc
- locale_sort
- locale_to_ascii
- locale_num2text
- locale_format_currency
- locale_format_date
- array_sort
- array_punch
- array_filter
- array_sublist
- deep_copy
- log_owner
- use_counter
- use_junk
- keep_deleted
- auto_id
- buffer_write
- simple
- no_write
- no_backup
- jnktype
- keys_only
- id_type
- language
- .db · .table · .dbase
- .inx · .fld · .src
- .fac · .srt · .slg
- .unq · .del · .aut
- .cnt · .txn · .amberdb
- .csv · .cache · .tmp