Adds DB API for repositories

Adds DB API operations on repositories, including checks for
existence and duplication of parent relations.

Partially Implements Issue #48