What entity should entity_id be joined on? I'm writing a complex custom query to get order information from a Drupal Commerce install for export.

The table field_data_commerce_customer_address has a column entity_id. I've tried to join that field on order_id, but my results are incorrect. It doesn't match to user id... hmm.

What field should I join entity_id on?

And, more generally, is there a drupal entity informational function that would tell me what columns should be joined to what? Or a master entity table, or anything? Some central location that would tell me things like this so I don't have to dig around?

Looking around the database and googling but haven't found it yet.
The customer addresses are linked to the user, see https://drupal.stackexchange.com/a/121356/2322 for more details on this, so you've got an order that references a customer profile and this references a user.

It doesn't show this part, but find a more complete description about the commerce entities in this documentation page: http://www.drupalcommerce.org/user-guide/products



In any case, I'd definitely use Entity Field Query for this, it will save you from digging in the database and it will give you a more consistent way to access your data.