You’ve finished adding fields to both of your tables, including the ID fields intended to join the two tables together. But the tables don’t actually have a connection between them yet. In this section, you’ll set up that connection, called a relationship.
In the Learn phase, you learned about how to connect tables by establishing relationships between them. Now it’s time to do the same thing in your solution.
Connect your main and secondary tables by establishing a relationship between them.
- Choose the File menu > Manage > Database… ⇧⌘D
- Select the Relationships tab at the top of the window.
You should see a table occurrence for each table you created in your file. Here are the table occurrences in the example solution:
- Connect the table occurrences by joining the ID field that they have in common — that is, the primary key in the main table and the foreign key in the secondary table.
In the example solution, this is the “Contact ID” field.
- Select the Allow creation of records option for the secondary table — not the main one.
This will allow people to create new records in the secondary table by entering data into the last row in a portal.
- Don’t select the Delete related records… option.
This is a powerful feature that causes records to be deleted when a connected record in the other table is deleted. For example, if you delete a Contact, all its connected Activities would be deleted automatically. While this can be very convenient, it can cause data loss if not handled properly. We recommend that you avoid this option until you learn more about it.
- Don’t select the Sort records option.
In the Learn phase, you sorted the relationship for convenience. However, this can cause performance issues if your solution gets very large. So it’s better to get in the habit of sorting records only when you need to.
- Click the OK button to close the Manage Database… dialog window.
You are returned to your layout.