×
英文
很抱歉,此文章目前沒有您所使用語言的版本。

Course summary: Create table relationships (Access basics, part 2)

Why relationships

They link your tables, so they’re a critical part of your database, and they inform your queries.

Relationship types

One-to-one, one-to-many, and many-to-many. One-to-many is most common, many-to-many are part of most transaction and student databases, 1:1 is rare.

Create a one-to-many

In datasheet view, select your foreign key or a blank field.

  • Foreign key: Select the field, then Fields > More Fields> Lookup & Relationship, and follow the wizard.

  • Blank field: Select the header, then Lookup & Relationship and follow the wizard.

Use the Relationships pane

Child table must have a foreign key. Select Database Tools > Relationships, then drag the primary key from the parent table to the foreign key in the child table. Use Edit Relationshipsto set referential integrity, and cascading updates/deletes as needed.

Many-to-many

Create > Table Design, create a junction table. In that table, duplicate the primary keys from the tables on both sides of the relationship, select both fields and set them as a composite key.

One-to-one

Create a one-to-many relationship, then:

  • Design view: Set the Indexed property for both keys to “No,” or “Yes, No Duplicates.”

  • Ribbon, set both keys to Indexed and Unique.

See also

增進您的 Office 技巧
探索訓練
優先取得新功能
加入 Office 測試人員

這項資訊有幫助嗎?

感謝您的意見反應!

感謝您的意見反應! 我們將協助您與我們的其中一個 Office 支援專員連絡以深入了解您的意見。

×