Relationships between tables in Access

In this article, go with TipsMake.com to learn more about how to establish a relationship.The nn relationship is the relation between two tables, a record of table A can have multiple records matching in table B and vice versa.

To create such a relationship, define the third table, called a join table, with the primary key including foreign keys from both Table A and Table B to divide the nn relationship into two 1-n relationships. .

Continuing with the examples in the previous tutorial, we added a tblTacgia table and a link table tblTacgiaNoi. The Author table includes the schools TacgiaID, Ten, Ho, Diachi, Dienthoai, Email, Ngaysinh.

Relationships between tables in Access Picture 1
Add new table tblag has fields as shown

Often an author will work with many projects, as well as a project that can have many authors working together. As in the previous tutorials, the tblDuAn table also has an author field, so we will create a separate table that includes information about the author. So, we don't need this field in the Project table anymore.

Relationships between tables in Access Picture 2
The tblDuAn table also has a field about Authors

Choose Tacgia school , press the delete button and you will see the following message.

Relationships between tables in Access Picture 3
Delete the TacGia field on this table

Click Yes .

Now we will create a link board. This connector has two foreign keys as follows:

Relationships between tables in Access Picture 4
Add 2 ID fields of the two tables to this join table

These foreign key fields will be primary keys from both tables tblTg and tblDuAn.

To create multiple keys in Access, select both of these fields, go to the Design tab , click Primary Key, the selected fields will become keys.

Relationships between tables in Access Picture 5
The two selected fields all become keys

Save the table with the name tblTacgiaNoi.

Next, go to the Relationship in the Design tab to create a relationship by clicking Show Table.

Relationships between tables in Access Picture 6
Add 3 tblDuAn tables, tblTacgia and tblTacgiaNoi

Select the tblDuAn, tblTacgia and tblTacgiaNoi tables, click Add to add all three tables to the desktop and close the Show Table dialog box .

Relationships between tables in Access Picture 7
All 3 tblDuAn, tblTacgia and tblTacgiaNoi tables are added to the screen

Using the mouse to click and hold the TacgiaID field in tblTacgia table , drag to the TacgiaID field you want to connect to the table tblTacgiaNoi. When you release the mouse, Access opens the Edit Relationships window . Note, the relationship that is creating Access will be considered a 1-n relationship. Click the Cascade Update box and click Create:

Relationships between tables in Access Picture 8
Pulling together two TacgiaID fields of two tables will display the Edit Relationships dialog box

Result:

Relationships between tables in Access Picture 9

Next, drag the DuAnID field from the tblDuAn table to the DuAnID field of the tableTableGoogle, and check the Enforce Referential Integrity box and Cascade Update Related Fields .

Relationships between tables in Access Picture 10
Drag the two DuAnID fields of the two tables together to display the Edit Relationships dialog box

And this is the relationship we want to establish:

Relationships between tables in Access Picture 11
Relationship nn

Previous article: 1-n relationship between tables in Access

Next lesson: Wildcard representation operator in Access

5 ★ | 1 Vote

May be interested

  • MS Access 2003 - Lesson 39: Analyzing tablesMS Access 2003 - Lesson 39: Analyzing tables
    access includes a very powerful tool that you can use to analyze data in one or more tables.
  • MS Access 2003 - Lesson 15: Create an initial tableMS Access 2003 - Lesson 15: Create an initial table
    in this section, you are ready to create a table for the new database. in chapter 2, you used the table wizard to create tables easily. this not only shows that creating a table manually is difficult; but it is a sure way to understand the table.
  • Work with data in Access 2016Work with data in Access 2016
    in the previous lesson, you became familiar with the access 2016 interface as well as the opening and closing of the basic database. this article will continue to go deeper into access 2016 around the content of working with data in access 2016.
  • MS Access 2003 - Lesson 12: Working with a tableMS Access 2003 - Lesson 12: Working with a table
    you have learned how to create and design tables in access. and now it's time to learn how to manipulate all tables.
  • Create data queries in Access 2016 from simple to complexCreate data queries in Access 2016 from simple to complex
    the query allows to retrieve information from one or more tables based on the search conditions you defined. in this lesson, you will learn how to create queries on a simple table and query on multiple tables in access 2016.
  • How to Link Tables in AccessHow to Link Tables in Access
    microsoft access allows tables and databases to connect with each other. this capability can increase your efficiency and easily spread information that is required for multiple departments or reports. you can make changes in the original...
  • MS Access 2003 - Lesson 8: Change information in the tableMS Access 2003 - Lesson 8: Change information in the table
    in the previous section, you learned how to use the datasheet view mode to enter information for the table. the datasheet view mode also allows you to edit available information quickly and easily.
  • Advantages of MongoDBAdvantages of MongoDB
    any relation database has a unique schema design to index the data tables and relationships between those tables. meanwhile in mongodb there is no concept of relationship.
  • Table in CSSTable in CSS
    tables in html can become much more beautiful thanks to css.
  • Steps to create relationships between multiple tables using Data Model in ExcelSteps to create relationships between multiple tables using Data Model in Excel
    excel is a powerful tool for data analysis and automation after processing large data sets. you can spend considerable time analyzing tons of data using vlookup, index-match, sumif...