![]() It can have an index, but it must allow duplicates. The field on the many side should not have a unique index. This means that the Indexed property for this field should be set to Yes (No Duplicates). To create a one-to-many relationship The field on the one side (typically the primary key) of the relationship must have a unique index. If both fields have a unique index, Access creates a one-to-one relationship. This means that the Indexed property for these fields should be set to Yes (No Duplicates). To create a one-to-one relationship Both of the common fields (typically the primary key and foreign key fields) must have a unique index. In addition, again only if you selected the Enforce Referential Integrity check box, the number 1 appears over the thick portion on one side of the relationship line, and the infinity symbol ( ∞) appears over the thick portion on the on the other side of the line, as shown in the following figure. If you selected the Enforce Referential Integrity check box, the line appears thicker at each end. ![]() For more information about referential integrity, see the section Enforce Referential Integrity.Īccess draws a relationship line between the two tables. To enforce referential integrity for this relationship, select the Enforce Referential Integrity check box. If a field name is incorrect, click on the field name and select the appropriate field from the list. Verify that the field names shown are the common fields for the relationship. The Edit Relationships dialog box appears. To drag multiple fields, press the CTRL key, click each field, and then drag them. After you have finished adding tables and queries to the Relationships document tab, click Close.ĭrag a field (typically the primary key) from one table to the common field (the foreign key) in the other table. Select one or more tables or queries and then click Add. On the Design tab, in the Relationships group, click Add Tables (or Show Table in Access 2013). On the Database Tools tab, in the Relationships group, click Relationships. ![]() Top of Page Create a table relationship by using the Relationships window When both common fields are Number fields, they must have the same FieldSize property setting. For example, you can match an AutoNumber field and a Number field if the FieldSize property of both fields is Long Integer. If the primary key field is an AutoNumber field, however, the foreign key field can also be a Number field if the FieldSize property of both fields is the same. The common fields must have the same data type. ![]() When you create a relationship between tables, the common fields are not required to have the same names, although it is often the case that they do. In the Relationships window, add the tables that you want to relate, and then drag the field to relate them from one table to the other table.ĭrag a field on to a table datasheet from the Field List pane. In an Access database, you create a table relationship using one of the following methods: In this articleĬreate a table relationship by using the Relationships windowĬreate a table relationship by using the Field List pane to add a fieldĬreate, edit, or delete a relationship in a Web AppĬreate or modify a relationship in an Access 2010 web database For more information, see Guide to table relationships and Get started with table relationships. A relationship can also help prevent missing data, by keeping deleted data from getting out of synch, and this is called referential integrity.īefore you work with relationships, make sure you understand the background concepts. When you use related tables in a query, the relationship lets Access determine which records from each table to combine in the result set. Each record in the OrderDetails table has a ProductID that corresponds to a record in the Products table with the same ProductID. For example, you might have a ProductID field in a Products table and in an OrderDetails table. Each relationship consists of fields in two tables with corresponding data. A relationship in Access helps you combine data from two different tables. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |