Support foreign keys.

I have modified GuysFawks commit to be clearer. This add support for foreign key.