fixed database, relations and added training managing