Module
Contents
Index 🔎︎

# 关系

此命令可打开关系设计窗口，可以在其中定义各种数据库表格之间的关系。

在此可以通过公用数据字段将当前数据库中的表格链接在一起。单击新建关系图标或只通过鼠标拖放操作来创建关系。

要访问此命令...

In a database file window, choose Tools - Relationships.

此功能仅适用于关系数据库。

When you choose Tools - Relationships, a window opens in which all the existing relationships between the tables of the current database are shown. If no relationships have been defined, or if you want to relate other tables of the database to each other, then click on the Add Tables icon. The Add Tables dialog opens in which you can select the tables with which to create a relation.

插入表格

如果关系设计窗口处于打开状态，则即使在表格设计模式下也无法修改选定的表格。这样可以确保在创建关系的过程中表格不会被修改。

The selected tables are shown in the top area of the relation design view. You can close a table window through the context menu or with the Delete key.

### 移动表格并修改表格大小

可以根据需要来排列表格并改变其大小。要移动一个表格，拖动其上边框到希望放置的位置。要放大或缩小一个表格的显示比例，则拖动其边框或一个角，直到得到想要的大小。

## Primary key and foreign keys

If you want to define a relation among the various tables, you should enter a primary key that uniquely identifies a data field of an existing table. You can refer to the primary key from other tables to access the data of this table. All data fields referring to this primary key will be identified as a foreign key.

主关键字指定的数据字段在表格窗口中用一个小的关键字图标标明。

## 定义关系

All existing relations are shown in the relations windows by a line that connects the primary and foreign key fields. You can add a relation by using drag-and-drop to drop the field of one table onto the field of the other table. A relation is removed again by selecting it and pressing the Delete key.

另外，您也可以通过单击关系字段上方区域中的新建关系图标，在关系对话框中定义两个表格之间的关系。

新建关系

If you use LibreOffice as the front-end for a relational database, the creation and deletion of relationships is not placed in an intermediate memory by LibreOffice, but is forwarded directly to the database.

双击连接线打开关系对话框，可以在其中指定关系的某些属性。