About Self-Relationships
Not only can you relate one table to another, you can also relate records within a table to each other. This is called a self-relationship. There are lots of situations where self- relationships are useful. If you have a table of names containing many contacts that work for the same company, you can create a self-relationship in a portal to list everyone working for the same company on each individual employee's record. Portal entries can be defined as buttons to switch between records. You can also use a self-relationship to do simple finds, create summary fields, and even create lookups to speed up data entry.
To create a self-relationship
1 .Choose File > Define > Database (Control+Shift+D/Command+Shift+D). When the Define Database dialog box appears, click the Relationships tab.2 .Click the Edit Relationships button. When the Edit Relationships dialog box appears, choose the name of the current table in both drop-down lists (Figure 6.44). In this case, the table is called Customer.
Figure 6.44. To create a self-relationship, choose the current table name in both table lists.
[View full size image]

Figure 6.45. Choose the same field name in both field lists.

Figure 6.46. Choose the Sort Order for a relationship by double-clicking the field name on the left.

Figure 6.47. Always give relationships a descriptive title.

To display and access self-relationship data
1 .Switch to the layout that will display the related data and choose View > Layout Mode (Control+L/Command+L).2 .Make sure the layout has enough room for the portal. If it doesn't, drag the Body tab down to resize the part.3 .Click the Portal tool. Click on the layout and drag the pointer out and down to size.4 .In the Portal Setup dialog box that appears, click the "Show related records from" drop-down menu and choose the Contacts by Company table occurrence for this portal (Figure 6.48). Click OK.
Figure 6.48. Choose the table occurrence that the portal will use to relate records.

Figure 6.49. When you create a portal on a layout, the Add Fields to Portal dialog box automatically appears.

Figure 6.50. In Browse mode, the portal will display the records from the related tables.
[View full size image]

