Created by Github action <!-- mintlify-editor-comments:start --> Mintlify --- 0 threads from 0 users in Mintlify - No unresolved comments <!-- mintlify-editor-comments:end --> <!-- mintlify-comment--> <a href="https://dashboard.mintlify.com/twenty/twenty/editor/i18n-docs?source=pr_comment" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://d3gk2c5xim1je2.cloudfront.net/assets/open-mintlify-editor-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://d3gk2c5xim1je2.cloudfront.net/assets/open-mintlify-editor-light.svg"><img src="https://d3gk2c5xim1je2.cloudfront.net/assets/open-mintlify-editor-light.svg" alt="Open in Mintlify Editor"></picture></a> <!-- /mintlify-comment --> Co-authored-by: github-actions <github-actions@twenty.com>
61 lines
1.8 KiB
Plaintext
61 lines
1.8 KiB
Plaintext
---
|
|
title: 创建关系字段
|
|
description: 通过关系字段逐步将对象连接起来。
|
|
---
|
|
|
|
关系字段可连接不同对象的记录——例如,将人员链接到公司。
|
|
|
|
<Note>
|
|
**关系名称在创建后无法更改**(它们会影响 API)。 请谨慎规划名称。
|
|
</Note>
|
|
|
|
## 开始之前
|
|
|
|
请确定:
|
|
|
|
* 要连接哪些对象? (例如,人员 → 公司)
|
|
* 哪一方是“一”端? (例如,公司)
|
|
* 哪一方是“多”端? (例如,人员—许多人在同一家公司工作)
|
|
* 两端的字段应如何命名?
|
|
|
|
请参阅[关系字段](/l/zh/user-guide/data-model/capabilities/relation-fields),了解关系类型的说明。
|
|
|
|
## 步骤
|
|
|
|
1. 进入 **设置 → 数据模型**
|
|
2. 选择要创建关系的对象(通常为“多”端)
|
|
3. 点击 **+ 添加字段**
|
|
4. 将字段类型选择为 **关系**
|
|
5. 选择**目标对象**
|
|
6. 选择 **一对多** 或 **多对一**
|
|
7. 为关系的**两端**输入字段名称
|
|
8. 单击 **保存**
|
|
|
|
## 示例:人员 → 公司
|
|
|
|
* 进入 **设置 → 数据模型 → 人员**
|
|
* 添加关系字段
|
|
* 目标:**公司**
|
|
* 类型:**多对一**
|
|
* 人员中的字段:**公司**
|
|
* 公司中的字段:**员工**
|
|
|
|
现在,每个人员都可以关联到一家公司,每家公司都会显示其人员。
|
|
|
|
## 删除关系
|
|
|
|
1. 进入 **设置 → 数据模型**
|
|
2. 找到该关系字段
|
|
3. 点击 **⋮ → 停用**
|
|
|
|
关联会被保留但隐藏。 重新启用即可恢复。
|
|
|
|
<Note>
|
|
**删除关系不会删除记录。** 只会移除它们之间的关联。
|
|
</Note>
|
|
|
|
## 相关内容
|
|
|
|
* [关系字段](/l/zh/user-guide/data-model/capabilities/relation-fields) — 类型和限制
|
|
* [如何导入关系](/l/zh/user-guide/data-migration/how-tos/import-relations-between-objects-via-csv) — 批量导入关联记录
|