-
Notifications
You must be signed in to change notification settings - Fork 0
TR Concept Repeat Blocks
Turkce Dokumantasyon | English Documentation
Kategori: Mimari Kavramlar ve Prensipler
Alt Sistem: Veri Modeli ve Dinamik Tablolar (AmberDB::Base&AmberDB::Index)
Madde Turu: Ileri Seviye Veri Modeli Rehberi
Tekrarli Genisleyen Bloklar (Repeat Blocks), iliskisel veritabanlarinda (RDBMS) 1-to-N (Bire-Cok) iliskiler icin ayri alt tablolar (order_items, invoice_lines, product_attributes) acma ve sorgularda pahali JOIN islemleri yapma zorunlulugunu ortadan kaldiran AmberDB ozelligidir.
AmberDB'de bir ana kayit (ornegin bir Siparis), baslik bilgilerinin ardindan istedigi kadar dinamik alt satiri (siparis kalemleri) tek bir kayit icinde yatay olarak tasiyabilir. Motor; semada tanimlanan repeat_start ve repeat_ids kurallarina gore bu alt satirlardaki urun/oge ID'lerini otomatik olarak toplar, virgulle birlestirir ve indeksler.
Tekrarli Blok Dizi Anatomisi (@record)
[0..14] Sabit Ust Alanlar [15] 1. Alt Satir [16] 2. Alt Satir [17]...
┌───────────────────────────────────┐ ┌───────────────────────────┐ ┌───────────────────────────┐
│ ID, Musteri, Tarih, Tutar, ... │ │ ["101", "MacBook", 1, ..] │ │ ["102", "Mouse", 2, ..] │
└───────────────────────────────────┘ └───────────────────────────┘ └───────────────────────────┘
│ │ │
│ └──────────────┬──────────────┘
v v
[12] repeat_ids (Otomatik Doldurulur) ──────────────────────> "101,102" (match_block ile indekslenir)
Tablo semasinda (schema/*.table) iki ozel anahtar yapilandirilir:
-
repeat_start: Tekrarlayan alt satirlarin basladigi blok indeksini belirtir (Orneginrepeat_start => 15). -
repeat_ids: Motorun alt satirlardaki birincil ID'leri otomatik toplayip virgulle birlestirecegi hedef blok numarasidir (Orneginrepeat_ids => 12).
# dbstore/schema/order_master.table
{
name => "Siparisler",
repeat_ids => 12, # Alt urun ID'lerinin toplanacagi indeks blogu (Orn: "101,102,103")
repeat_start => 15, # 15. bloktan itibaren baslayan tekrarlayan satirlar
match_block => [ 2, 12 ], # 12. blok match_block'a eklenerek alt urun ID'siyle arama saglanir!
fields => [
{ id => "id", name => "Siparis ID", type => "num" },
{ id => "customer_id", name => "Musteri ID", type => "num" }, # 1
{ id => "order_date", name => "Siparis Tarihi",type => "date" }, # 2
# ... (Diger sabit alanlar 3..11) ...
{ id => "product_ids", name => "Urun Dongusu", type => "text" }, # 12 (repeat_ids hedefi)
{ id => "order_total", name => "Toplam Tutar", type => "num" }, # 13
{ id => "status", name => "Durum", type => "num" }, # 14
{ id => "items", name => "Urun Kalemleri",type => "repeat" }, # 15 (repeat_start sablonu)
],
}Her insert_id, modify_id, insert_list veya modify_list cagrisinda motor (repeat_fields):
-
@record[15..$#record]dilimindeki tum alt satirlari tarar. - Her bir alt satirin 1. elemanini (Urun ID'si) alir.
- Bu ID'leri virgulle birlestirip (
"101,102,103") otomatik olarak12.bloga (repeat_ids) yazar. - Gelistiricinin 12. blogu elle doldurmasina gerek yoktur; motor bunu kayit yazilirken otomatik uretir.
use AmberDB;
my $adb = AmberDB->new(path => { dbase_dir => "./dbstore" });
# 1. Siparis kaydi olusturma (Sabit alanlar + 15'ten baslayan alt satirlar)
my @siparis = (
0, # [0] Otomatik Siparis ID
1001, # [1] Musteri ID
"2026-09-01", # [2] Tarih
"", "", "", "", "", "", "", "", "", # [3..11] Diger alanlar
"", # [12] repeat_ids (Motor tarafindan otomatik doldurulacak)
74998.00, # [13] Toplam Tutar
1, # [14] Durum: Onaylandi
# 15. Blok ve sonrasi: Tekrarlayan Urun Kalemleri ([UrunID, Baslik, Adet, Fiyat])
[ 101, "MacBook Pro M3", 1, 64999.00 ], # [15] 1. Kalem
[ 102, "Magic Mouse 3", 1, 9999.00 ], # [16] 2. Kalem
);
# 2. Kaydi ekle
my $siparis_id = $adb->insert_id("order_master", @siparis);
# 3. Geri okuyup kontrol edelim:
my @okunan = $adb->read_id("order_master", $siparis_id);
print "Otomatik Derlenen Urun ID'leri: $okunan[12]\n"; # "101,102"
# 4. Alt kalem Urun ID'si uzerinden TUM SIPARISLERI tek sorguda bulma:
# 101 numarali urunun gectigi tum siparisleri aninda listele ($O(1) fld aramasi!)
my ($toplam, @siparisler) = $adb->field_fetch("order_master", 12 => 101);
print "101 Nolu urunu iceren $toplam adet siparis bulundu!\n";-
Sifir SQL JOIN Maliyeti: Siparis ve kalemleri tek bir BDB kaydinda tutulur; tek bir
$O(1)$ disk okumasiyla siparis tum satirlariyla birlikte belleğe gelir. -
Cift Yonlu Hizli Arama:
match_block => [12]sayesinde "Hangi siparislerde 101 nolu urun satildi?" sorusu milisaniyeden kisa surede yanitlanir. - Atomik Butunluk: Siparis guncellendiginde veya silindiginde alt kalemler de ayni transaction icinde tek hamlede guncellenir/silinir; yetim (orphan) satir riski yoktur.
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