Refactoring tbl_relation.php