Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By peterk900 on
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
You can define the foreign
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...
Thanks
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 ?
Views relationships are not
Views relationships are not determined by the schema, you need to set them up in hook_views_data().
Yes, my stupidity. That's
Yes, my stupidity. That's good - off to look again at hook_views_data ! Thanks for this.