Wednesday, October 26, 2011

CDB - constant database

This is my official 3rd web job, and I got to learn a new database, CDB.

I tested freecdb in UBuntu.

To install
sudo apt-get install freecdb

To create a database file (native) :
cdbmake <db file name> <temporary file name> < <record file name>

* remember to have the record file to have a new line at the end of the file to indicate end of record.



<record file name> format :
+<key length>,<value length>:<key>-><value>

Test the database :
cdbtest < <database file name>

To dump database :
cdbdump < <database file name>

To get a record :
echo `cdbget <key> < <database file name>`

To print out database statistic
cdbstats < test.cdb

For more details on cdb : http://cr.yp.to/cdb.html

This database is good for simple database design, and data is populated during creation. As its name represent, the database should be static after creation, and used for data retrieval purpose. Thus, you don't see any update/insert/delete command in cdb.

1 comment: