协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
relation-creation【开发与工程】Guides you through defining a relationship between two Honeydew entities — covering join type, direction, cross-filtering, and connection method — then pushes the updated entity YAML to Honeydew via the MCP tools.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Before creating relations, ensure you are on the correct workspace and branch. Use get_session_workspace_and_branch to check the current session context. For development work, create a branch with create_workspace_branch (the session switches automatically). See the workspace-branch skill for the full workspace/branch tool reference.
A Honeydew relation defines how two entities join together.
Relations are not standalone objects — they live inside the source entity's YAML as a relations: block.
Every relation connects the "many" side to the "one" side: for example, orders (many) → customers (one).
Relations enable:
Relations are defined on the source entity. To add a relation, use
update_objecton the entity that holds the foreign key (the "many" side).
There is no create_relation tool. Adding a relation means updating the source entity's YAML to include the relations: block.
Call update_object with:
yaml_text — the full updated entity YAML with the relations: blockobject_key — the entity's object key (find via list_entities or get_entity)Required permission: Editor or higher.
After a successful update_object call, the response includes a ui_url field. Always display this URL to the user so they can quickly open the object in the Honeydew application.
There is no delete_object for relations. To remove a relation, update the source entity's YAML with the relation removed from the relations: block.
get_entity on both entities and check which one has the relation in its relations: block.relations: list (keep all other relations intact).update_object with the updated YAML and the entity's object_key.Need to define a relation?
│
├─► Simple FK join (equality on one or more columns)?
│ └─► Use field-based connection
│ connection:
│ - src_field: <fk_column>
│ target_field: <pk_column>
│
├─► Complex join (range, filter, SCD Type 2, multi-entity)?
│ └─► Use expression-based connection
│ connection_expr:
│ sql: |-
│ <custom SQL>
│
└─► Removing an existing relation?
└─► Use update_object — remove relation from entity YAML
See examples.md for full worked examples covering: field-based join, composite key, expression-based (SCD Type 2), multiple relations, many-to-many through a bridge table, and removing a relation.
For any shape these do not cover, search the Honeydew documentation with search_docs and query_docs_filesystem before improvising — it carries more relationship-modeling detail than this skill does. See Documentation Lookup for what to search for.
Use these MCP tools before defining relations:
get_entity — Get entity details including existing relations, attributes, and YAML definitionlist_entities — List all entities (to identify source and target)search_model — Search for entities or fields by name (use search_mode: EXACT for known names, OR for broad discovery)See reference.md for: YAML schema, relation direction (rel_type), join types, cross-filtering options, and connection methods.
When you arrive from the entity-creation skill with a freshly validated entity, or a batch of them from import_tables, nothing is connected yet and there is no list of joins to work from. Build one:
entity-creation skill and validate it first.Confirm the one side actually has a key — an import_tables entity may arrive with none, and validation checks key uniqueness, not key presence. Set the key before relating to it.
Search for the FK with search_model in OR mode, since an attribute is often renamed from the column it maps to and EXACT matches the attribute name only; narrow a large model with entity.field syntax (orders. returns every field of matching entities). If an entity yields no candidate at all, get_table_info on its source table will show whether the FK exists in the warehouse but was never mapped as an attribute.
One entity often connects to a fact more than once in different roles — a users entity that is the salesperson on one relation, the support agent on another. Those roles are not the same thing, and a single shared entity makes them look like one.
customers entity used by orders and by tickets). Relate all of them to the one entity.entity-creation skill (sales_reps, support_agents) and give each its own relation, so each role carries its own name, filters and metrics.The tell is whether the two paths would ever be filtered or reported on together as one population. If not, it is role playing.
IMPORTANT: Before creating any relations, analyze the modeling options and present them to the user for decision.
Steps:
list_entities and get_entityDo not assume a single correct answer. Relationship modeling involves trade-offs (query performance, maintainability, analytical flexibility) that depend on the user's specific needs.
Confirm anything non-trivial with the user before building it. SCD Type 2 and other effective-dated joins, range joins, multiple paths between the same two entities, and role playing are all easy to infer confidently and get wrong. The developer knows facts about the schema that are not visible in it — which of two paths is the intended one, whether a date range is inclusive, which role a given FK plays. Propose, then ask; do not build a chain of inferred relations in one pass.
Use the search_docs and query_docs_filesystem tools from the honeydew MCP server to search the Honeydew documentation when:
Search for topics like: "relations", "joins", "cross-filtering", "many-to-one", "relationship modeling".
rel_type: many-to-one.connection_expr for cases that genuinely require custom SQL.connection.cross_filtering: both unless performance is a concern. Restrict to one-to-many or none for large entities.relations: block — omitting an existing relation will delete it.After creating ANY relation, you MUST invoke the validation skill to test and validate.
See the validation skill (Entities → "Validating Relations") for:
get_entityQuick validation:
get_entity on the source entity, check its relations list.get_data_from_fields:attributes: ["<target_entity>.<attribute>"]metrics: ["<source_entity>.<metric>"]update_object replaces the full entity YAML. If the entity already has relations, fetch the current YAML first (via get_entity) and include all of them in the update.connection. A partial key join produces fan-out and incorrect aggregations.connection_expr without enforcing cardinality. Custom SQL joins bypass Honeydew's cardinality validation. A poorly written expression can silently produce many-to-many joins.many-to-one cross-filtering on large tables. Filtering from the "many" side back to the "one" side requires a reverse join and is expensive. Use none or one-to-many unless the use case requires it.