ArticleslgStudy

computer science

Berkeley DB

Berkeley DB is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Berkeley DB rather than just read about it. In short: Berkeley DB (BDB) is an embedded database software library for key–value data, historically significant in open-source software. Berkeley DB is written in C, with API bindings for many other programming languages.

Key takeaways

  • Berkeley DB belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Berkeley DB to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Berkeley DB from memory before moving on to harder problems.

Reference excerpt

Berkeley DB (BDB) is an embedded database software library for key–value data, historically significant in open-source software. Berkeley DB is written in C, with API bindings for many other programming languages. BDB stores arbitrary key–data pairs as byte arrays and supports multiple data items for a single key. Berkeley DB is not a relational database, although it has database features, including database transactions, multiversion concurrency control and write-ahead logging. BDB runs on a wide variety of operating systems, including most Unix-like and Windows systems, and real-time operating systems. BDB was commercially supported and developed by Sleepycat Software from 1996 to 2006. Sleepycat Software was acquired by Oracle Corporation in February 2006, who continued to develop and sell the C Berkeley DB library. In 2013, Oracle re-licensed BDB under the AGPL license and released new versions until May 2020. Bloomberg L.P. continues to develop a fork of the 2013 version of BDB within their Comdb2 database, under the original Sleepycat permissive license.

Origin Berkeley DB originated at the University of California, Berkeley as part of BSD, Berkeley's version of the Unix operating system. After 4.3BSD (1986), the BSD developers attempted to remove or replace all code originating in the original AT&T Unix from which BSD was derived. In doing so, they needed to rewrite the Unix dbm database package. Seltzer and Yigit created a new database, unencumbered by any AT&T patents: an on-disk hash table that outperformed the existing dbm libraries. Berkeley DB itself was first released in 1991 and later included with 4.4BSD. In 1996 Netscape requested that the authors of Berkeley DB improve and extend the library, then at version 1.86, to suit Netscape's requirements for an LDAP server and for use in the Netscape browser. That request led to the creation of Sleepycat Software. This company was acquired by Oracle Corporation in February 2006. Berkeley DB 1.x releases focused on managing key–value data storage and are referred to as "Data Store" (DS). The 2.x releases added a locking system enabling concurrent access to data. This is what is known as "Concurrent Data Store" (CDS). The 3.x releases added a logging system for transactions and recovery, called "Transactional Data Store" (TDS). The 4.x releases added the ability to replicate log records and create a distributed highly available single-master multi-replica database. This is called the "High Availability" (HA) feature set. Berkeley DB's evolution has sometimes led to minor API changes or log format changes, but very rarely have database formats changed. Berkeley DB HA supports online upgrades from one version to the next by maintaining the ability to read and apply the prior release's log records. Starting with the 6.0.21 (Oracle 12c) release, all Berkeley DB products are licensed under the GNU AGPL. Previously, Berkeley DB was redistributed under the 4-clause BSD license (before version 2.0), and the Sleepycat Public License, which is an OSI-approved open-source license and an FSF-approved free software license. The product ships with complete source code, build script, test suite, and documentation. The comprehensive feature along with the licensing terms have led to its use in a multitude of free and open-source software. Those who do not wish to abide by the terms of the GNU AGPL, or use an older version with the Sleepycat Public License, have the option of purchasing another proprietary license for redistribution from Oracle Corporation. This technique is called dual licensing. Berkeley DB includes compatibility interfaces for some historic Unix database libraries: dbm, ndbm and hsearch (a System V and POSIX library for creating in-memory hash tables).

Architecture Berkeley DB has an architecture notably simpler than relational database management systems. Like SQLite and LMDB, it is not based on a client–server model, and does not provide support for network access – programs access the database using in-process API calls. Oracle added support for SQL in 11g R2 release based on the popular SQLite API by including a version of SQLite in Berkeley DB (it uses Berkeley DB for storage). A program accessing the database is free to decide how the data is to be stored in a record. Berkeley DB puts no constraints on the record's data. The record and its key can both be up to four gigabytes long. Berkeley DB supports database features such as ACID transactions, fine-grained locking, hot backups and replication.

Oracle Corporation use of name "Berkeley DB" The name "Berkeley DB" is used by Oracle Corporation for three different products, only one of which is BDB:

Berkeley DB, the C database library that is the subject of this article Berkeley DB Java Edition, a pure Java library whose design is modelled after the C library but is otherwise unrelated Berkeley DB XML, a C++ program that supports XQuery, and which includes a legacy version of the C database library

Open-source programs still using Berkeley DB BDB was once very widespread, but usage dropped steeply from 2013 (see licensing section). Notable software that still uses Berkeley DB for data storage include:

Bogofilter – A free/open-source spam filter that saves its wordlists using Berkeley DB by default. Citadel/UX – A collaborative software (messaging and groupware) that is directly descended from the Citadel family of programs, which became popular in the 1980s and 1990s as a bulletin board system platform. Citadel still supports Berkeley DB for existing sites, but now uses LMDB for new installations. Exim - A free/open-source MTA used on Unix-like operating systems. Sendmail – A free/open-source MTA, first released in 1983 for Linux/Unix systems. Spamassassin – A free/open-source anti-spam application. Open-source operating systems and languages such as Perl and Python still support old Berkeley DB interfaces. The FreeBSD and OpenBSD operating systems ship Berkeley DB 1.8x to support the dbopen() operating system call used by password programs such as pwb_mkdb. Linux operating systems, including those based on Debian, and Fedora ship Berkeley DB 5.3 libraries.

Licensing Berkeley DB V2.0 and higher is available under a dual license:

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Berkeley DB

Start with the simplest possible case. Write down what Berkeley DB claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Berkeley DB before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Berkeley DB ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Berkeley DB

In research
Berkeley DB appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Berkeley DB in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Berkeley DB is common in secondary-school and first-year university syllabi. It links to neighbouring topics Database-related software for Linux, Database engines, Embedded databases, so understanding it makes those chapters shorter.
In everyday life
Look for Berkeley DB outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Berkeley DB” →

How to study Berkeley DB in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Berkeley DB means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Berkeley DB out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Berkeley DB in simple terms?

Berkeley DB (BDB) is an embedded database software library for key–value data, historically significant in open-source software. Berkeley DB is written in C, with API bindings for many other programming languages.

Why does Berkeley DB matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Berkeley DB?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Berkeley DB.

Tags

  • Database-related software for Linux
  • Database engines
  • Embedded databases
  • Free database management systems
  • Free software programmed in C
  • Key-value databases
  • NoSQL
  • Oracle software
  • Software using the GNU Affero General Public License
  • Structured storage

Keep exploring