DBM (computing)
{{Short description|Key-value database management system}}
{{About|the family of database engines||DBM (disambiguation){{!}}DBM}}
{{refimprove|date=January 2022}}
In computing, a DBM is a library and file format providing fast, single-keyed access to data. A key-value database from the original Unix, dbm is an early example of a NoSQL system.
History
The original dbm library and file format was a simple database engine, originally written by Ken Thompson and released by AT&T in 1979. The name is a three-letter acronym for DataBase Manager, and can also refer to the family of database engines with APIs and features derived from the original dbm.
The dbm library stores arbitrary data by use of a single key (a primary key) in fixed-size buckets and uses hashing techniques to enable fast retrieval of the data by key.
The hashing scheme used is a form of extendible hashing, so that the hashing scheme expands as new buckets are added to the database, meaning that, when nearly empty, the database starts with one bucket, which is then split when it becomes full. The two resulting child buckets will themselves split when they become full, so the database grows as keys are added.
The dbm library and its derivatives are pre-relational databases{{snd}} they manage associative arrays, implemented as on-disk hash tables. In practice, they can offer a more practical solution for high-speed storage accessed by key, as they do not require the overhead of connecting and preparing queries. This is balanced by the fact that they can generally only be opened for writing by a single process at a time. An agent daemon can handle requests from multiple processes, but introduces IPC overhead.
Implementations
The original AT&T dbm library has been replaced by its many successor implementations. Notable examples include:
- ndbm ("new dbm"), based on the original dbm with some new features.
- [https://www.gnu.org.ua/software/gdbm/gdbm.html GDBM] ("GNU dbm"), GNU rewrite of the library implementing ndbm features and its own interface. Also provides new features like crash tolerance for guaranteeing data consistency.{{cite web |title=Crash Tolerance |website=GDBM manual |url=https://www.gnu.org.ua/software/gdbm/manual/Crash-Tolerance.html |access-date=3 October 2021}}{{cite web |title=Crashproofing the Original NoSQL Key-Value Store |url=https://queue.acm.org/detail.cfm?id=3487353 |access-date=3 October 2021}}
- sdbm ("small dbm"), a public domain rewrite of dbm. It is a part of the standard distribution for Perl and is available as an external library for Ruby.{{cite web |last1=yigit |first1=ozan |title=sdbm.bun |website=cse.yorku.ca |url=http://www.cse.yorku.ca/~oz/sdbm.bun |access-date=8 May 2019}}{{cite web |title=Ruby SDBM library |website=SDBM on Github |url=https://github.com/ruby/sdbm |quote=Note that Ruby used to ship SDBM in the standard distribution up until version 2.7, after which it was made available only as an external library, similarly to the DBM and GDBM libraries, removed from the standard library in Ruby 3.1.}}
- qdbm ("Quick Database Manager"), a higher-performance dbm employing many of the same techniques as Tokyo/Kyoto Cabinet. Written by the same author before they moved on to the cabinets.{{cite web |date=2006 |title=QDBM: Quick Database Manager |website=fallabs.com |url=https://fallabs.com/qdbm/ |access-date=2020-02-27 |archive-date=2020-02-27 |archive-url=https://web.archive.org/web/20200227064151/https://fallabs.com/qdbm/ |url-status=dead }}
- tdb ("Trivial Database"), a simple database used by Samba that supports multiple writers. Has a gdbm-based API.{{cite web |title=tdb: Main Page |website=tdb.samba.org |url=https://tdb.samba.org/}}
- Berkeley DB, 1991 replacement of ndbm by Sleepycat Software (now Oracle) created to get around the AT&T Unix copyright on BSD. It features many extensions like parallelism, transactional control, hashing, and B-tree storage.
- LMDB: copy-on-write memory-mapped B+ tree implementation in C with a Berkeley-style API.
The following databases are dbm-inspired, but they do not directly provide a dbm interface, even though it would be trivial to wrap one:
- cdb ("constant database"), database by Daniel J. Bernstein, database files can only be created and read, but never be modified
- Tkrzw, an Apache 2.0 licensed successor to Kyoto Cabinet and Tokyo Cabinet
- WiredTiger: database with traditional row-oriented and column-oriented storage.
Availability
As of 2001, the ndbm implementation of DBM was standard on Solaris and IRIX, whereas gdbm is ubiquitous on Linux. The Berkeley DB implementations were standard on some free operating systems. After a change of licensing of the Berkeley DB to GNU AGPL in 2013, projects like Debian have moved to LMDB.{{cite mailing list |last=Surý |first=Ondřej |date=19 June 2014 |title=New project goal: Get rid of Berkeley DB (post jessie) |mailing-list=debian-devel |publisher=Debian |url=https://lists.debian.org/debian-devel/2014/06/msg00338.html}}
Reliability
A 2018 AFL fuzzing test against many DBM-family databases exposed many problems in implementations when it comes to corrupt or invalid database files. Only freecdb by Daniel J. Bernstein showed no crashes. The authors of gdbm, tdb, and lmdb were prompt to respond. Berkeley DB fell behind due to the sheer amount of other issues;{{cite web |last=Debroux |first=Lionel |date=16 Jun 2018 |title=oss-security - Fun with DBM-type databases... |website=openwall.com |url=https://www.openwall.com/lists/oss-security/2018/06/17/1}} the fixes would be irrelevant to open-source software users due to the licensing change locking them back on an old version.
See also
References
{{reflist|refs=
{{harvnb|Kew|2007|p=80}}: "DBMs have been with us since the early days of computing, when the need for fast keyed lookups was recognized. The original DBM is a UNIX-based library and file format for fast, highly-scalable keyed access to data. It was followed (in order) by NDBM ('new DBM'), GDBM ('GNU DBM'), and the Berkeley DB. This last is by far the most advanced, and the only DBM under active development today. Nevertheless, all of the DBMs from NDBM onward provide the same core functionality used by most programs, including Apache. A minimal-implementation SDBM is also bundled with APR, and is available to applications along with the other DBMs.
Although NDBM is now old - like the city named New Town ('Neapolis') by the Greeks in about 600BC and still called Naples today - it remains the baseline DBM. NDBM was used by early Apache modules such as the Apache 1.x versions of mod_auth_dbm
and mod_rewrite
. Both GDBM and Berkeley DB provide NDBM emulations, and Linux distributions ship with one or other of these emulations in place of the 'real' NDBM, which is excluded for licensing reasons. Unfortunately, the various file formats are totally incompatible, and there are subtle differences in behaviour concerning database locking. These issues led a steady stream of Linux users to report problems with DBMs in Apache 1.x."
}}
Bibliography
{{refbegin}}
- {{cite book |last=Hazel |first=Philip |year=2001 |title=Exim: The Mail Transfer Agent |publisher=O'Reilly |url=https://books.google.com/books?id=AcLDAQAAQBAJ&pg=PT500}}
- {{cite book |last1=Ladd |first1=Eric |last2=O'Donnell |first2=Jim |year=2001 |title=Using XHTML, XML and Java 2: Platinum Edition |publisher=Que |isbn=9780789724731 |url=https://books.google.com/books?id=NLc_TQiWvo4C&pg=PA823}}
- {{cite book |last=Kew |first=Nick |year=2007 |title=The Apache Modules Book: Application Development with Apache |publisher=Prentice Hall Professional |isbn=9780132704502 |url=https://books.google.com/books?id=HTo_AmTpQPMC&pg=PA80}}
{{refend}}
- [https://apr.apache.org/docs/apr-util/0.9/group__APR__Util__DBM__SDBM.html SDBM library] @Apache
- {{cite book |last1=Matthew |first1=Neil |last2=Stones |first2=Richard |year=2008 |title=Beginning Linux Programming |chapter=Databases |publisher=Wiley |url=https://books.google.com/books?id=vvuzDziOMeMC&pg=PT270}}
- {{cite web |last1=Olson |first1=Michael A. |last2=Bostic |first2=Keith |last3=Seltzer |first3=Margo |year=1999 |title=Berkeley DB |work=Proceedings of the FREENIX Track:1999 USENIX Annual Technical Conference |url=http://www.usenix.org/events/usenix99/full_papers/olson/olson.pdf}}