An ultra-fast persistent database for high performance programs written in C


It has its roots in EDA tool development. This domain needs fast calculations on a lot of related objects. Datadraw is designed to lay out it's objects in a cpu-cache friendly way. This leads to fast programs. To achieve this, you need to layout your relationships. Datadraw will generate C-code for it that you can use in your programs. It is plain C and rather crossplatform, it also has some handy utilitiies.


What is it?

(In-memory) (Graph) database.

How cool is it?



Rust, STL, raw pointers in c or c++.

When to use it?

When you want to write blazing fast code for a specific domain with a lot of objecs and relations.

Is it dead?

Nope, But it seems so matured that development is stalled.

Where is it?

How to use it

The documentation is extensive but has some minor inconsistancies.




mkdir tmp
cd ./tmp
wget -q -O datadraw-3.1.1.tar.gz
tar -xaf datadraw-3.1.1.tar.gz 
cd datadraw3.1.1/

Debian ships with the dash shell as 'sh'



for i in `find tmp -name 'configure'`; do sed -i.bak -e "s/bin\/sh/bin\/bash/g" $i ; done

Build the library



cd ./tmp/datadraw3.1.1
cd dataview
sed -i.bck -e "s/^datadraw /..\/datadraw /" configure


Typically you need to create a description for your data-domain. Datadraw is excellent with relations between objects. It generates macro's and functions to keep your memory sane. We will follow the example from paragraph 20.19.

file: netlist.dd

module Netlist nl

class Port
	sym name

class Instance
relationship Instance Port doubly_linked mandatory

class Net
relationship Net Port doubly_linked

class Netlist
relationship Netlist Instance hashed mandatory
relationship Netlist Net hashed mandatory

file: main.c

#include "nldatabase.h"

nlInstance nlInstanceCreate( nlNetlist netlist, utSym sym) {
	nlInstance instance = nlInstanceAlloc();

	nlInstanceSetSym(instance, sym);
	nlNetlistAppendInstance(netlist, instance);

	return instance;

nlNet nlNetCreate( nlNetlist netlist, utSym sym) {
	nlNet net = nlNetAlloc();

	nlNetSetSym(net, sym);
	nlNetlistAppendNet(netlist, net);

	return net;

nlPort nlPortCreate( nlInstance instance, utSym sym) {
	nlPort port = nlPortAlloc();

	nlPortSetName(port, sym);
	nlInstanceAppendPort(instance, port);

	return port;

int main(void) {
	nlNetlist netlist;
	nlInstance instA, instB;
	nlNet net;
	nlPort portA, portB;


	netlist = nlNetlistAlloc();

	instA = nlInstanceCreate(netlist, utSymCreate("instA"));
	portA = nlPortCreate(instA, utSymCreate("portA"));

	instB = nlInstanceCreate(netlist, utSymCreate("instA"));
	portB = nlPortCreate(instB, utSymCreate("portB"));

	net = nlNetCreate(netlist, utSymCreate("net"));

	nlNetAppendPort(net, portA);
	nlNetAppendPort(net, portB);

	/* Do whatever you like with the netlist here... */


	return 0;



./tmp/datadraw3.1.1/datadraw netlist.dd
./tmp/datadraw3.1.1/dataview/dataview netlist.dd
gcc -o ./tmp/main \
	-I./tmp/datadraw3.1.1/util \
	nldatabase.c main.c \

dataview reads the netlist.dd and create a pdf with the database scheea. datadraw reads the netlist.dd and creates the file 'nldatabase.h', 'nldatebase.c' wich can be used for further compilation.

Further reading:

We only tipped the top of the iceberg here. There is much more:

  • handy embedding of sparse data
  • unions with enum
  • embed your own structs/objects/types in the data with typedef
  • make the module persistant instead of volitile, with a handy load/dump utility
  • make the module awesome with undo/redo
  • load other modules and c/h files in your code

Next to that, the ddutil library has several handy stuff for

  • memory allocation
  • string allocation, manipulation and formatting
  • File and directory access
  • randomnumber generator
  • logging
  • errorhandling