add relationships in ORM to prevent delete errors

when relationships aren't configured, sqlalchemy does not know in what
order to delete rows, so sometimes child relationships were
randomly deleted before the parent
fix primary and foreign key declarations in ORM models

Composite foreign keys need to be declared using ForeignKeyConstraint,
otherwise sqlalchemy generated 2 seperate forign key constraints.
refactor func key tests, move helpers into test_dao
fix naming convention
implement template_dao.remove_func_key_from_templates

when deleting a destination (i.e. a user) we need to
remove the func key from all templates, since the func key
will no longer work