[#76864570] data consistency report with database foreign keys

Squashed commit of the following:

commit 439afbf257f310d3d273ff2ab1525844389c7704
Author: Franco Sellitto <franco.sellitto@zhdk.ch>
Date:   Mon Sep 15 12:15:26 2014 +0200

    introducing database foreign keys