Berkeley DB
Berkeley DB (BDB) is a open source, high-performance, embedded database library with bindings in C, C++, Java, Perl, PHP, Ruby, Python, Tcl, Smalltalk and many other programming languages.
Some of the benefits of BDB are: zero administration (embedded in application), extreme performance (no SQL or interprocess communication), and low cost of ownership.
Contents
History[edit]
Berkeley DB was first developed at the University of California, Berkeley as part of the transition from BSD 4.3 to 4.4 and the effort to replace AT&T's NDBM and the ASearch library.
Netscape asked the Berkeley DB authors to improve and extend the library to suit their requirements for an LDAP server and the Netscape browser. That request led to the creation of Sleepycat Software (1996), which was acquired by Oracle Corporation in February 2006.
Architecture[edit]
Berkeley DB has a hugely simplified architecture compared with the Oracle database. For example, it doesn't provide support for network access.
Berkeley DB 11g R2 added support for SQL based on the popular SQLite API. Also, PL/SQL is available as a third party solution from Metatranz StepSqlite.
Access to Berkeley DB is via programmatic API's only. As the database is embedded into an application, no DBA is required to manage and maintain the database. A program accessing the database is free to decide how the data will be stored - using records with keys. The database puts no constraints on a record's data. Programmers will typically choose a delimiter character to distinguishes between fields in a record. The record and its key can both be up to 4GB long.
Berkeley DB normally outperforms relational and object-oriented databases because it runs in the same address space as the application - no inter-process communication required. It also uses a simple function-call interface for all operations, there is no query language to parse, and no execution plan to produce.
Database editions[edit]
Berkeley DB is available in 3 editions:
- Berkeley DB - the original C library
- Berkeley DB JE (Java Edition) - pure Java version optimized for the Java environment
- Berkeley DB XML - XML database with XQuery and XPath support
Applications using Berkeley DB[edit]
Berkeley DB is used within products like:
- MySQL (one of the available storage engines, also see InnoDB)
- Subversion (version control system like CVS)
- OpenLDAP (free/open source implementation LDAP)
Etc.
Licensing[edit]
Berkeley DB is available under dual license:
- Public license that requires that software that uses the Berkeley DB code be free/open source software; and
- Closed source license for non-open source software.
If your code is not redistributed, no license is required (free for in-house use).
Example[edit]
Here is a simple perl program that uses BerkeleyDB to store and retrieve data:
use BerkeleyDB; $key = 'root'; @data = (0, 0, 'SuperUser', '/root', '/bin/tcsh'); $db = new BerkeleyDB::Hash(-Filename => 'data.dbm', -Flags => DB_CREATE ) or die "Cannot open file: $!"; $db->db_put($key, join(':', @data)); $db->db_get($key, $val); ($uid, $gid, $name, $home, $shell) = split ':', $val; print "$key:\t$uid|$gid $name\t$home\t$shell\n"; $db->db_close();