From Bauman National Library
Revision as of 07:44, 21 April 2016 by igor nikolaev (Talk | contribs)

Metakit is an efficient embedded database library with a small footprint. It fills the gap between flat-file, relational, object-oriented, and tree-structured databases, supporting relational joins, serialization, nested structures, and instant schema evolution. There is a C++ API, a Python binding called Mk4py, and a Tcl binding called Mk4tcl. You can manipulate and exchange data between any of these.

Data files are portable. The library has been used on Unix, Windows, Macintosh, VMS, and others, spanning a range of 16- to 64-bit architectures, from PDA's to S390's.

Metakit is in use in various commercial projects and products on millions of desktops.



  • Both the code and datafiles are portable. All byte-ordering managed by the library.
  • Store multiple nested data structures, to create document-centric applications.
  • You'll have to see this to believe it: restructure files on-the-fly, while open.
  • Complementing commit/rollback of changes, data can also be serialized.
  • The use of Stable Storage ensures that files cannot be corrupted by crashes.
  • Files are opened without reading data. Memory-mapped files if O/S supports it.
  • The API mimics container classes. Quickly get sizes and iterate over rows.
  • Sorting, relational join / group by, set operations, permutations, hashing.
  • The largest int defines storage format. String/binary data is stored as var-sized.
  • Can be linked shared or statically, for hassle-free deployment of components.
  • The library is extremely small, unused functions are stripped off in static links.
  • Only a small interface is exposed. One header file lists all the classes you need.
  • Use from Python and Tcl



The documentation for the C++ API is generated by Doxygen. There are also some older docs and an intro from the pre-2.3 days. There is C++ sample code in the demo/ and examples/ areas of the source code distribution.

Riccardo Cohen has written a small tutorial with some nice code examples, see his Metakit C++ tutorial on the web.

Further information can be gleaned from the 140+ small C++ snippets which form the regression test suite in the tests/ directory.


The Mk4py page describes the use of MK from Python. There is Python sample code in the examples/ area of the source code distribution.

An annotated, newer version of the above has been created by Brian Kelley, with several examples, explaining new features such as hashes and ordered views.


The Mk4tcl page describes the procedural interface from Tcl to MK. Mark Roseman has written a tutorial for Mk4tcl, which is an excellent way to get started in Tcl. There is Tcl sample code in the examples/ area of the source code distribution.

There is a newer Oomk binding (Object Oriented MK) which exposes more of MK's C++ core to Tcl, i.e. like the Python binding. It is based on Mk4too (a relatively unknown part of Metakit for Tcl which is best left alone now that Oomk exists).

The "Starkits" chapter in the 4th edition of Practical Programming in Tcl and Tk by Brent Welch includes documentation about the Mk4tcl binding.