Lesson 4: Adding a referential constraint to the model

In this lesson, you will add a reference between tables in a database model. Before you begin, complete:“Lesson 3: Adding indexes to the model”.

  1. Open the Modeling Tool Palette. Select Window|Show View|Other. When the Show View dialog box opens, select Sybase|Modeling Tool Palette and click OK.

  2. Click the Reference tool to select it in the Tool Palette, which is located on the WorkSpace main window.

    NoteYou can also find the options available on the Modeling Tool Palette at the top of the editor in a toolbar.

  3. Click the salesdata table in the editor diagram, hold down the mouse button and drag the cursor to the warehouse_inventory table, then release the mouse button.

    This creates a reference link from the salesdata table to the warehouse_inventory table. The salesdata table is the child and the warehouse_inventory table is the parent.

    The item_num column in the warehouse_inventory table appears as a foreign key in the salesdata table. This is indicated by the symbol <fk>, shown in the preceding graphic.

  4. Save the Physical Data Model with a new name:

    1. Click the pointer tool (arrow cursor) on the Table editor toolbar to release the Reference tool.

    2. In the Model Explorer view, select the Local tab, then double-click the icon next to the default model name, PhysicalDataModel_1.

      The Model Properties dialog box appears.

    3. Enter MySybStoreDBModel in the Name field and click OK to close the Model Properties dialog box.

    4. Select the MySybStoreDBModel on the Model Explorer Local tab, then select File|Save to save the model. You have added a reference between tables to a database model.