Merge pull request #1 from twinge/add_relationship_logic

Add relationship api logic
Fix adding an index when a relationship is created