Derby is a lightweight embedded relational database implemented completely in Java. It is an embedded database for any Java applications.[05][06]
- Source Code
- https://github.com/apache/derby[02]
- @apachederby
- Developer
- Governance
- Apache Software Foundation
- Country of Origin
- US
- Start Year
- 1997 [07]
- End Year
- 2025 [30]
- Former Names
- JBMS, Cloudscape, Java DB
- Acquired By
- Project Type
- Open Source
- Written in
- Java
- Supported Languages
- Java
- Operating System
- All OS with Java VM
- License
- Apache v2
History[07][08][09]
In 1997, Cloudscape Inc., a start-up in Oakland, California, developed a database engine called JBMS, which was later renamed as Cloudscape. From 1999 to 2001, Cloudscape was acquired first by Informix Software, and by IBM, and its name was changed to IBM Cloudscape. In 2004, IBM contributed the code to the Apache Software Foundation as Derby. The Apache DB project, supported by Apache Software Foundation, aims at creating and maintaining open-sourced, high-quality databases. In 2005, Derby exited the incubator and became a Apache DB subproject.
In October 2025, the project announced that the system is going into "read-only mode" since nobody was actively maintaining the system anymore.
Checkpoints[10]
Derby supports fuzzy checkpointing with slight variations from the ARIES implementation. Instead of storing an active transaction table and a dirty page table in checkpoints, Derby instead stores a few timestamps, including the checkpoint start time and the earliest start time of ongoing transaction when the checkpoint starts. For example, if transaction T1, T2 and T3 are not finished when the checkpoint starts, then the earliest start time of the three will be recorded in the checkpoint.
When it comes to recovery, the system will first find the nearest checkpoint. Using the earliest start time of ongoing transactions, it will iterate through the log and find all the active transactions and dirty pages at the checkpoint, and redo or undo accordingly.
Compression[11]
Derby does not support data compression, but it supports the function syscs_util.syscs_compress_table which is used to claim unused space after deletion of large amount of data.
Concurrency Control[12][13]
There are two scopes of locking (table-level and row-level), three types of locks (exclusive, shared and update) and four different types of transaction isolation levels. The locking strategies for different combination of scopes, lock types and isolation levels are different.
In general, although not explicitly stated, Derby implements strict two-phase locking. Exclusive locks will be held until a transaction aborts or commits; shared lock, instead, will be released after the reading of the rows finish (except for specific isolation levels)
Derby also supports deadlock detection. When a deadlock is detected, the transaction that holds the least number of locks will be aborted.
Foreign Keys[15]
Foreign key is implemented as one of the CONSTRAINT clauses. There are two levels of CONSTRAINTS, column level and table level. Foreign key constraint in a column level enforces that the values in the column must corresponds to the values in the referenced column marked as primary key or unique key. Table level constraint works similarly, but it is for multiple columns.
Insert, update or delete instructions will return an error if the foreign key constraint is violated. The constraint check can be at statement execution or commit depending on the constraint mode.
Indexes[16]
Derby implements standard B+ Tree algorithms with a few features:
-
It only uses exclusive latches on pages regardless of reading or modification of the page;
-
Node split is always left to right;
-
The system holds at most 2 latches simultaneously. During insertion, if there is no space for node splitting, all latches will be released, and Derby will do a split pass from top to bottom. After the split pass, Derby will redo the Insertion operation again.
Isolation Levels[12][17]
Derby supports four level of isolation: serializable, repeatable read, read committed and read uncommitted for both table-level and row-level locking. The isolation levels can be set by either JDBC methods or SQL statements. One thing to highlight is that under repeatable read isolation level, row-level locking may create repeatable read. However, table-level locking will not, because the entire table will be locked.
Joins[18]
Derby provides two types of join strategies -- nested loop and hash join. Nested loop join is more preferable in most cases. Hash join is preferred when inner table values are unique and outer table have many qualifying rows. Also, when the system estimates that the amount of memory required for hash join exceeds the amount available, nested loop will be used.
Logging[19][16]
Derby implements Write Ahead Logging (WAL) similar to the ARIES design. One of the differences is that instead of saving Log Sequence Number (LSN) in the page data, it saves the page version numbers in both the page data and the log records, and compare them during recovery.
Derby implements page-level physical logging. For queries that involves more than one pages, the operation will first be converted to loggable actions for each page involved. Then the loggable actions will be used to generate physical logging on that page.
Query Compilation[20][21]
Derby parses the prepared statement using Javacc and generates the Java binary code directly. JIT complier is supported, so that after several executions, JIT compiler will compile it to native code for performance improvement.
Storage Architecture[23][24][13]
Derby mainly support on-disk database. It also provides in-memory database for testing and developing applications. By following backup procedures, in-memory database can be stored and be used as either an in-memory database or normal on-disk database at a later time.
Storage Model[25]
Derby implements row-based storage model. Rows corresponds to records in data pages.
Storage Organization[26]
Derby stores data and index in containers, which has a one-to-one mapping with files. Within each container, there will be three types of pages -- header page, data page and allocation page. Data pages hold data in row order.
Stored Procedures[27]
Derby support Java stored procedures using the syntax CREATE PROCEDURE. Several parameters will be passed in, such as parameter style (Java or Derby), data type and Java method name. Note that several data types, such as BLOB, CLOB, LONG and VARCHAR cannot be used in stored procedures.
System Architecture[28]
Using JDBC driver, the Derby database can be embedded in the application and runs inside the same JVM.
Views[29]
Derby provides virtual views which are not updatable. The command to create a view is CREATE VIEW.
Citations
30 sources- Apache Derby apache.org
- GitHub - apache/derby: Mirror of Apache Derby · GitHub github.com
- Apache Derby: Documentation apache.org
- Apache Derby - Wikipedia wikipedia.org
- https://wiki.apache.org/db-derby/ apache.org
- Apache Derby apache.org
- Apache Derby Project Charter apache.org
- Welcome to the Apache DB Project! apache.org
- Proposal for Derby: an Apache Database Sub-Project apache.org
- Derby Logging and Recovery apache.org
- SYSCS_UTIL.SYSCS_COMPRESS_TABLE system procedure apache.org
- Types and Scope of Locks in Derby Systems apache.org
- Derby Developer's Guide apache.org
- https://builds.apache.org/job/Derby-docs/lastSuccessfulBuild/artifact/trunk/out/ref/refderby.pdf apache.org
- CONSTRAINT clause apache.org
- org.apache.derby.impl.store.access.btree apache.org
- Isolation levels and concurrency apache.org
- Join strategies apache.org
- Derby Logging and Recovery apache.org
- https://db.apache.org/derby/binaries/ApacheDerbyInternals_1_1.pdf apache.org
- Derby Engine Architecture Overview apache.org
- Derby Reference Manual apache.org
- https://builds.apache.org/job/Derby-docs/lastSuccessfulBuild/artifact/trunk/out/getstart/getstartderby.pdf apache.org
- https://builds.apache.org/job/Derby-docs/lastSuccessfulBuild/artifact/trunk/out/devguide/derbydev.pdf apache.org
- Derby On Disk Page Format apache.org
- Derby On Disk Page Format apache.org
- CREATE PROCEDURE statement apache.org
- Step 3: Embedded Derby apache.org
- CREATE VIEW statement apache.org
- https://issues.apache.org/jira/browse/DERBY-7177 apache.org