set_visible_foreign_keys
Control which related tables show in UI views by setting the visible-foreign-keys annotation. Stage changes until apply_annotations().
Instructions
Set the visible-foreign-keys annotation on a table.
Controls which related tables (via inbound foreign keys) appear in different UI contexts and their order. These show as "related tables" sections in the detailed view.
Changes are staged locally until apply_annotations() is called.
Args: table_name: Name of the table. annotation: The visible-foreign-keys annotation value. Set to null/None to remove.
Visible-Foreign-Keys Annotation Schema (tag:isrd.isi.edu,2016:visible-foreign-keys):
{
"detailed": [...], // Related tables in detailed view
"*": [...] // Default for all contexts
}Foreign key directive formats (items in the lists):
Inbound foreign key reference (array of [schema, constraint_name]):
["schema_name", "fkey_constraint_name"]The constraint must be an INBOUND foreign key (i.e., another table references this table).
Pseudo-column for related entities (object):
{ "source": [ {"inbound": ["schema", "fkey_to_this_table"]}, {"outbound": ["schema", "fkey_to_related"]}, "column_name" ], "sourcekey": "predefined_key", // OR reference to source-definitions "markdown_name": "Related Items", "comment": "Tooltip text", "display": { "markdown_pattern": "...", "template_engine": "handlebars" } }
Returns: JSON with status and the table name.
Examples: # Show specific related tables in detailed view set_visible_foreign_keys("Subject", { "detailed": [ ["domain", "Image_Subject_fkey"], ["domain", "Diagnosis_Subject_fkey"] ] })
# Hide all related tables
set_visible_foreign_keys("Subject", {"detailed": []})
# Pseudo-column for complex relationship
set_visible_foreign_keys("Subject", {
"detailed": [
{
"source": [{"inbound": ["domain", "Image_Subject_fkey"]}],
"markdown_name": "Subject Images"
}
]
})
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| annotation | No | ||
| table_name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |