Defining Constraints

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Tutorials > "ZooDB" Database >

Defining Constraints

In the previous section, you have added tables and created relations between them. You may want to control which data is added to your database tables, or simplify data entry by defining default values for certain columns.

 

Objective

In this section of the tutorial, you will learn how to use the Design Editor to create columns that can contain only unique or limited data, or have a predefined standard value. Specifically, you will learn how to do the following:

 

Define a unique constraint for a column
Add check constraints on column and table level
Provide columns with default values

 

Commands used in this section

Icon

Command name

Description


Show in new Design Editor

This command is located in the context menu that opens when you right-click a database object in the Online Browser. Click this command to open a new Design Editor window and display the selected database object in it.

ic_unique-key-constraint

Make Unique Key

This command is located in the context menu that opens when you right-click a column in a table design. Click this command to define a unique key on the selected column.

ic_execute-sql

Execute Change Script

This command is located in the toolbar of the Database Structure Change Script window. Click this command to execute the recorded change script and to commit the changes to the database.

ic_check-constraint

Insert new | Check Constraint

This command is located in the context menu that opens when you right-click somewhere into a table design. Click this command to define a new check constraint for the table.

ic_default-value-column

Create Default Constraint

This command is located in the context menu that opens when you right-click a column in a table design. Click this command to define a default constraint for the selected column.

ic_edit

Edit Data

This command is located in the SQL and Data sub-menu of the context menu that opens when right-clicking a table design. Choose this command to generate an SQL SELECT statement that is automatically executed in the SQL Editor and switches the Result window into the Editing mode. This command works for all supported database kinds for both ADO and ODBC connections.

ic_show-design-options

Options...

This command is located in the Tools menu. Click this command to display the Options dialog box, where you can change the DatabaseSpy settings.

ic_add_line

Append a new row

This command is available as a button in the Result window toolbar. Click this button to add a new row to the result grid. Alternatively, you can also right-click anywhere in the result grid and choose Append a new row from the context menu. The Append a new row command is only available if the Result window is in the Editing mode.


© 2019 Altova GmbH