People Goal 1 - Part 11: Connect your tables

Document created by Kedar on Jan 26, 2015Last modified by communitymanager on May 12, 2015
Version 12Show Document
  • View in full screen mode

 


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.


Goal:

Connect your main and secondary tables by establishing a relationship between them.


Steps:

  1. Choose the File menu > Manage > Database…  ⇧⌘D

  2. Select the Relationships tab at the top of the window.
    pasted-image-12.png

    You should see a table occurrence for each table you created in your file. Here are the table occurrences in the example solution:
    pasted-image-13.png

  3. 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.
    pasted-image-14.png
  4. 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.

    pasted-image-15.png

  5. 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.

  6. 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.

  7. Click the OK button to close the Manage Database… dialog window.

    You are returned to your layout.



      

      

Attachments

    Outcomes