Db relations

@mnzaki please review and merge.