How do you create relationship between two tables in a database?
Answers
Explanation:
Create a table relationship by using the Relationships window
● On the Database Tools tab, in the Relationships group, click Relationships.
● On the Design tab, in the Relationships group, click Add Tables (or Show Table in Access 2013).
● Select one or more tables or queries and then click Add. After you have finished adding tables and queries to the Relationships document tab, click Close.
● Drag a field (typically the primary key) from one table to the common field (the foreign key) in the other table. To drag multiple fields, press the CTRL key, click each field, and then drag them.
Drag a field (typically the primary key) from one table to the common field (the foreign key) in the other table. To drag multiple fields, press the CTRL key, click each field, and then drag them.The Edit Relationships dialog box appears.
● Verify that the field names shown are the common fields for the relationship. If a field name is incorrect, click on the field name and select the appropriate field from the list.
for the relationship. If a field name is incorrect, click on the field name and select the appropriate field from the list.To enforce referential integrity for this relationship, select the Enforce Referential Integrity check box. For more information about referential integrity, see the section Enforce Referential Integrity.
● Click Create.
Click Create.Access draws a relationship line between the two tables. If you selected the Enforce Referential Integrity check box, the line appears thicker at each end. 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.
Notes:
■ 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. This means that the Indexed property for these fields should be set to Yes (No Duplicates). If both fields have a unique index, Access creates a one-to-one relationship.
■ 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. This means that the Indexed property for this field should be set to Yes (No Duplicates). The field on the many side should not have a unique index. It can have an index, but it must allow duplicates. This means that the Indexed property for this field should be set to either No or Yes (Duplicates OK). When one field has a unique index, and the other does not, Access creates a one-to-many relationship.
Answer:
Steps to create relationships:
★ You can create a relationship between any two tables by selecting the Relationships option from the Tools menu.
★ Add the tables amongst which you want to create the relationship. Select the tables and click on the Add button.
★ There are two ways to create the relationships between the tables:
◘ Click on Insert option and select New Relation option in Relation Design window.
◘ A dialog box appears set the tables involved, fields involved, update & delete options ->ok.
◘ Another way to create relationships is drag the primary key column from one table and drop it on the key column of another table.
Hope you got that.
Thank You.