How to add relationship in view for custom entity
Entity API supports this out of the box, but you will have to let it know which entity your data represents. If Entity API encounters a field containing numeric data it will by default assign it the type 'integer'. Just change the type to the right entity type and you can define the relations in Views:

&lt;?php
  /**
   * Implements hook_entity_property_info_alter().
   */
  function my_entity_entity_property_info_alter(&amp;$info) {
    $info['my_entity']['properties']['nid']['type'] = 'node';
    $info['my_entity']['properties']['uid']['type'] = 'user';
    $info['my_entity']['properties']['tid']['type'] = 'taxonomy_term';
  }
?&gt;