ZODB

The Zope Object Database (ZODB) is an object-oriented DBMS library for storing Python objects. ZODB aims to provide a transparent way for Python programmers to make their data persistent. It is completely written by Python, and only provides Python API. It does not support other programming languages.

ZODB stores data as objects, and the relationship between objects are automatically maintained by Python object references. As a result, ZODB allows programmers to manage data structures with complicate relationships.

The storage layer of ZODB is pluggable, and there are three main implementations: ZOE, NOE, and RelStorage. ZOE is a single-server client-server framework using FileStorage; NOE extends ZOE to distributed-server client-server storage; RelStorage stores objects in a relational database, such as MySQL, PostgreSQL, and Oracle.

ZODB uses aggressive caching. As a result, it is not suitable for tasks with heavy writes. Also, ZODB is designed for mapping access through keys and attributes of objects, which means that it does not support queries containing joins and advanced search.

History

ZODB was a commercial project dated back to the late 90s, and was made open source as ZODB1 in 2002. It quickly upgraded to ZODB2 and then to ZODB3 in the same year, 2002. ZODB3 lived until 2012, and then the developers decided to rebuild it into ZODB4 using 100% Python. In 2016, ZODB4 is renamed to ZODB5, which is the current version and is active. ZODB was born as a part of the Zope web application server, but it now stands alone and can be used independently.

Checkpoints

Not Supported

ZODB does not provide ckeckpoint API.

Joins

Not Supported

Relations between objects are maintained by Python object references.

Storage Architecture

Hybrid

ZODB has pluggable storage layers, among which the DemoStorage is a in-memory storage, and others are disk-oriented.

Query Compilation

Not Supported

ZODB does not support complex queries, so there is no need for query compilation.

Foreign Keys

Not Supported

System Architecture

Shared-Disk

It depends on which pluggable storage layer is used. The default storage layer ZEO is a single-server model, so there is no sharing. There are many distributed-server models written for ZODB, such as NEO and ZRS. NEO and ZRS store data on multiple machines across the Internet, and support data duplication, load-balancing read and fault tolerance.

Logging

Not Supported

The default storage layer, FileStorage in ZOE, is itself a log structured file. So there is no need to implement logging in ZODB.

Query Interface

Custom API

ZODB only provides Python API. Users query for an object in ZODB in the similar way to querying for a value in a Python dictionary.

Indexes

B+Tree

ZODB does not support building indexes in the traditional way. However, there is a data type named Btree functioning as an index in ZODB. If objects are stored in a Btree, they are maintained in order, and range queries are supported. Btree has variants optimized for integer keys and integer values.

Data Model

Object-Oriented

ZODB stores data as objects, and the relationship between objects are automatically maintained by Python object references.

Compression

Naïve (Page-Level)

The default storage implementation FileStorage does not compress the data. It simply appends object to the end of a file. However, there is an optional layer which uses gzip to compress the file in the FileStorage. Moreover, since ZODB has a pluggable storage layer, it also can support compression by using different storage layers such as NEO and relStorage. RelStorage supports MySQL, PostgreSQL, and Oracle backend.

Concurrency Control

Multi-version Concurrency Control (MVCC)

ZODB implements MVCC as an additional layer for those pluggable storage layers without MVCC, such as ZEO and NEO. ZODB does not implement MVCC layer for relStorage, which already has MVCC.

Storage Organization

Log-structured Copy-on-Write / Shadow Paging

It depends on which pluggable storage layer is used. DemoStorage is a copy-on-write storage layer. FileStorage is a log-structured storage layer, which has only one large file for all data.

Stored Procedures

Supported

ZODB is used as a Python library. Therefore, Python functions can be viewed as stored procedures for ZODB.

Isolation Levels

Snapshot Isolation

ZODB supports snapshot isolation with MVCC.