What are the array entries if I want to define a relationship to another entity in the hook_schema function in a module .install file ? I've looked for an example snippet of code but can't find one. Thanks.

Comments

Jaypan’s picture

You can define the foreign keys property, but in D7 it's only for documentation purposes, they are not actually enforced. See the 'foreign keys' documentation here: https://api.drupal.org/api/drupal/includes%21database%21schema.inc/group...

peterk900’s picture

If they are not enforced, does this mean they won't allow a relationship to be set up in views thereby offering the selection of fields from the foreign table ?

Jaypan’s picture

Views relationships are not determined by the schema, you need to set them up in hook_views_data().

peterk900’s picture

Yes, my stupidity. That's good - off to look again at hook_views_data ! Thanks for this.