Adding chapter 4

This PR adds chapter 4 into the `master` branch.
Database stuff.