Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 » SQL Anywhere Server - SQL Usage » Creating Databases » Creating databases in SQL Anywhere » Tutorial: Creating a SQL Anywhere database

 

Lesson 5: Create a foreign key

In this lesson, you learn about creating relationships between tables using foreign keys. You use the tables you created in the previous lessons.

To create a foreign key
  1. In the left pane of Sybase Central, double-click Tables.

  2. In the left pane, click the SalesOrdersItems table to select it.

  3. In the right pane, select the Constraints tab.

  4. Choose File » New » Foreign Key.

  5. In the To Which Table Do You Want This Foreign Key To Refer list, select the Products table.

  6. In the What Do You Want To Name The New Foreign Key field, type ProductIDkey.

  7. Click Next and for Do You Want This Foreign Key To Reference The Primary Key Or A Unique Constraint choose Primary Key.

  8. In the Foreign Column list, click SalesOrdersItemsID.

  9. Click Finish.

This completes this introductory section on creating relational databases.

See also