Share via


How to: Set Temporary Relationships Between Tables

You can set temporary relationships between open tables in so that when the record pointer in one table moves, the record pointer in the other table follows. You can also create a temporary relationship in a single table.

Tip

Typically, you set a temporary relationship between tables that have a common field using a relational expression. The relational expression is typically the index expression of the controlling index in the child table.

For more information, see Temporary Relationships Between Tables.

To create a relationship between tables

  1. Open the tables you want to create relationships between.

  2. On the Window menu, choose Data Session.

    The Data Session window opens.

  3. In the Aliases list, click the alias for the parent table you want, and then Relations.

    The table you selected appears in the Relations list followed by a line indicating the relationship to a child table that you select in the next step.

  4. In the Aliases list, click the alias for the child table you want, and then the Relations.

    Note

    If an index order has not been set in the table you selected, the Set Index Order dialog box appears. To select an index order, click the index order you want to set in the child table, and then OK.

    The Expression Builder opens.

  5. In the Expression Builder, type or build a relational expression between the parent table and the child table. When you are finished, click OK.

For more information, see How to: Open Tables in Work Areas.

To create a one-to-many relationship between tables

  1. After you select the child table in the Data Session window, click 1 to many.

  2. In the Create One-to-Many Relationships dialog box, click the alias for the child table you want, and then Move.

  3. When you are finished, click OK.

To create a relationship in a single table

  1. Open the table you want in two separate work areas.

  2. On the Window menu, choose Data Session.

    The Data Session window opens.

  3. In the Aliases list, click the alias for the parent table you want, and then Relations.

  4. In the Aliases list, click the alias for the child table you want, and then Relations.

    Note

    If an index order has not been set in the table you selected, the Set Index Order dialog box appears. To select an index order, click the index order you want to set in the child table, and then OK.

    The Expression Builder opens.

  5. In the Expression Builder, type or build a relational expression between the parent table and the child table. When you are finished, click OK.

For more information, see How to: Open Tables in Work Areas.

To set a temporary relationship between tables programmatically

  • Use the SET RELATION command.

You can also use SET RELATION to establish a relationship between a single parent table and various child tables. You can also set a relationship between a table open in the currently selected work area and another table open in another work area by using the SET RELATION command. For more information, see SET RELATION Command.

See Also

Concepts

Temporary Relationships Between Tables

Other Resources

Managing Tables in Data Sessions

Working with Tables (Visual FoxPro)