As you mention "some relational stuff can be emulated" - the
DBI distribution now includes
DBD::DBM which layers a DBI/SQL interface over any DBM file, including BerkeleyDB files. It can operate either directly on the file, or make use of MLDBM with a serilaization method of your choice (Storable, Data::Dumper, etc.). The SQL is limited, but certainly covers the kinds of aggregate functions you mention as well as several kinds of joins.