Rules and Checks for Valid Data

To help ensure that the data in a database is valid, formulate checks that define valid and invalid data, and design the rules to which data must adhere.

Such rules are often called business rules. The collective name for checks and rules is constraints. Rules that maintain data integrity for a given column are column constraints. Rules that maintain integrity for one or more columns for a given table are table constraints. You can apply both table and column constraints to a single column in a table. Table constraints can also set the rule for a set of columns in a table.

Constraints that are built into the database itself are inherently more reliable than those built into client applications, or those spelled out as instructions to database users. Constraints built into the database are part of the database definition and can be enforced consistently across all applications.

Setting a constraint once, in the database, imposes it for all subsequent interactions with the database. By contrast, constraints that are built into client applications are vulnerable every time the software is altered, and may need to be imposed in several applications, or in several places in a single client application.

Declare any constraints that apply, whether or not SAP Sybase IQ enforces them. Declaring constraints ensures that you understand your data requirements, and are designing a database that matches the business rules of your organization.

SAP Sybase IQ performs several types of optimization based on the constraints you specify. This optimization does not depend on enforcement of constraints. For the best performance of queries and load operations, put all constraints in the database. FOREIGN KEY, PRIMARY KEY , UNIQUE, and IQ UNIQUE column constraints can improve load and query performance.

SAP Sybase IQ checks during load operations that certain constraints are obeyed. For example, SAP Sybase IQ ensures that data being loaded is the appropriate data type and length.