Some checks failed
App Prod-Parity E2E Dispatch / dispatch (push) Failing after 10s
CD Storybook UI / build (push) Failing after 3m25s
CD Storybook UI / dispatch (push) Has been skipped
CD deploy main / website-changed-files (push) Successful in 18m8s
CI Agent Skills / changed-files-check (push) Successful in 18m9s
CI Create App E2E minimal / changed-files-check (push) Successful in 24s
CI Create App / changed-files-check (push) Successful in 26s
CI Docs / changed-files-check (push) Successful in 26s
CI Emails / changed-files-check (push) Successful in 28s
CI Example App Hello World / changed-files-check (push) Successful in 23s
CI Front / changed-files-check (push) Has been skipped
CI Example App Postcard / changed-files-check (push) Successful in 27s
CI UI / changed-files-check (push) Has been skipped
CI Utils Test / changed-files-check (push) Successful in 45s
CI Twenty Apps / discover (push) Successful in 1m3s
CD deploy main / deploy-main (push) Failing after 3s
CI Agent Skills / agent-skills-validate (push) Has been skipped
CI Create App / create-app-test (lint) (push) Has been skipped
CI Emails / emails-test (push) Has been skipped
CI Front / front-task (lingui:compile) (push) Has been skipped
CI Front / front-task (lint) (push) Has been skipped
CI Example App Postcard / example-app-postcard (push) Has been skipped
CI UI / ui-task (lint) (push) Has been skipped
CI UI / ui-task (pack-size) (push) Has been skipped
CI UI / ui-task (size) (push) Has been skipped
CI UI / ui-task (test) (push) Has been skipped
CI UI / ui-task (typecheck) (push) Has been skipped
CI Utils Test / utils-test (push) Has been skipped
CI Twenty Apps / ${{ matrix.app.name }} (push) Has been skipped
CI Emails / ci-emails-status-check (push) Successful in 2s
CI Example App Hello World / ci-example-app-hello-world-status-check (push) Successful in 2s
CI Example App Postcard / ci-example-app-postcard-status-check (push) Successful in 3s
CI UI / ui-sb-test (push) Has been skipped
CI Utils Test / ci-utils-test-status-check (push) Successful in 2s
CI Twenty Apps / ci-twenty-apps-status-check (push) Successful in 2s
CI UI / ci-ui-status-check (push) Successful in 2s
CI Desktop / desktop (push) Failing after 1m8s
Push docs to Crowdin / Push documentation to Crowdin (push) Failing after 55s
Push translations to Crowdin / Extract and upload translations (push) Failing after 5s
Push website translations to Crowdin / Extract and upload website translations (push) Failing after 5s
CI Create App / create-app-test (test) (push) Has been skipped
CI Create App / create-app-test (typecheck) (push) Has been skipped
CI Docs / docs-lint (push) Has been skipped
CI Example App Hello World / example-app-hello-world (push) Has been skipped
CI Front / front-task (lingui:extract) (push) Has been skipped
CI Front / front-task (test) (push) Has been skipped
CI Front / front-task (typecheck) (push) Has been skipped
CI UI / ui-sb-build (push) Failing after 1m32s
CI Twenty Apps / ${{ matrix.app.name }} (${{ matrix.server-source }}) (push) Has been skipped
CI Agent Skills / agent-skills-publish (push) Has been skipped
CI Create App / ci-create-app-status-check (push) Successful in 2s
CI Agent Skills / agent-skills-remote-source (push) Has been skipped
CI Create App E2E minimal / create-app-e2e-minimal (push) Has been cancelled
CI E2E Main / e2e-test (push) Has been cancelled
CI Front / front-sb-build (push) Has been cancelled
CI Front / front-build (push) Has been cancelled
CI Create App E2E minimal / ci-create-app-e2e-minimal-status-check (push) Has been cancelled
CI E2E Main / ci-e2e-main-status-check (push) Has been cancelled
CI E2E Main / notify-main-ci-failure (push) Has been cancelled
CI E2E Main / qa-scout-comment (push) Has been cancelled
CI Front / front-sb-test (push) Has been cancelled
CI Front / front-sb-screenshots (push) Has been cancelled
CI Front / ci-front-status-check (push) Has been cancelled
DPA Sub-Processor Sync / sync-subprocessors (push) Failing after 3s
AI Catalog Sync / sync-catalog (push) Failing after 2s
95 lines
3.1 KiB
Plaintext
95 lines
3.1 KiB
Plaintext
---
|
||
title: 关系字段
|
||
description: 使用关系字段在不同对象之间关联记录。
|
||
---
|
||
|
||
## 关系类型
|
||
|
||
### 一对多
|
||
|
||
对象 A 中的一条记录可以关联到对象 B 中的多条记录。
|
||
|
||
**示例:** 一个公司可以拥有许多人员(员工)。
|
||
|
||
### 多对一
|
||
|
||
对象 A 中的多条记录可以关联到对象 B 中的一条记录。
|
||
|
||
**示例:** 许多人员可以隶属于一个公司。
|
||
|
||
### 可指向多种对象类型的关系
|
||
|
||
某些对象在关系的一侧可以关联到多种对象类型。
|
||
|
||
**示例:** 一条备注可以同时附加到一个人员、一个公司和一个商机。 该备注位于 "多" 侧,连接到多个 "一" 侧。
|
||
|
||
<img src="/images/user-guide/fields/many-to-one-morph.png" style={{width:'100%'}} />
|
||
|
||
类似地,一个项目(位于 "一" 侧)可以接收来自多个人员、多个公司和多条备注的关联。
|
||
|
||
<img src="/images/user-guide/fields/one-to-many-morph.png" style={{width:'100%'}} />
|
||
|
||
<Warning>
|
||
**导入/导出限制**:指向多个对象类型的关系目前尚不支持 CSV 导入/导出。 此功能已在我们的路线图中。
|
||
</Warning>
|
||
|
||
### 多对多
|
||
|
||
对象 A 中的多条记录可以关联到对象 B 中的多条记录。
|
||
|
||
**示例:** 许多人员可以关联到许多项目,反之亦然。
|
||
|
||
多对多关系采用**连接对象**模式:一个连接双方的中间对象。 借助连接关系功能,Twenty 会直接显示最终关联的记录,并在界面中隐藏该中间对象。
|
||
|
||
<Warning>
|
||
**Beta 功能**:使用前必须在 **Settings → Community → Features** 中启用连接关系。
|
||
</Warning>
|
||
|
||
请参阅 [如何创建多对多关系](/l/zh/user-guide/data-model/how-tos/create-many-to-many-relations) 以获取完整的分步指南。
|
||
|
||
## 创建关系字段
|
||
|
||
1. 进入 **设置 → 数据模型**
|
||
2. 选择要添加关系的对象
|
||
3. 点击 **+ 新字段**
|
||
4. 将字段类型选择为 **关系**
|
||
5. 选择要关联到的目标对象
|
||
6. 配置关系设置:
|
||
* **源对象上的字段名称**:你正在编辑的对象上的关系字段名称
|
||
* **目标对象上的字段名称**:将显示在目标对象上的关系字段名称
|
||
* 关系类型(一对多、多对一)
|
||
7. 单击 **保存**
|
||
|
||
## 标准关系
|
||
|
||
Twenty 内置了标准对象之间的预设关系:
|
||
|
||
| 来源对象 | 目标对象 | 关系类型 |
|
||
| ---- | ---- | ---- |
|
||
| 人员 | 公司 | 多对一 |
|
||
| 机会 | 公司 | 多对一 |
|
||
| 机会 | 人员 | 多对一 |
|
||
|
||
## 最佳实践
|
||
|
||
### 规划关系
|
||
|
||
* **梳理你的数据模型**:在创建关系之前先进行规划
|
||
* **考虑方向**:思考由哪个对象 "拥有" 该关系
|
||
* **避免循环依赖**:保持数据模型简洁清晰
|
||
|
||
### 关系命名
|
||
|
||
* **使用清晰的名称**:使关系所代表的含义一目了然
|
||
* **保持一致**:在各个关系中使用类似的命名模式
|
||
* **兼顾两端**:为关系的两端分别起合适的名称
|
||
|
||
### 性能
|
||
|
||
* **不要过度关联**:过多的关系会拖慢你的工作区
|
||
|
||
## 限制
|
||
|
||
* **删除关系**会移除链接,但不会删除相关记录
|
||
* **循环关系**应当避免,以确保数据完整性
|