Add db stuff and tests - end chapter 4a