数据库外文文献及翻译 第2页
table can't be modified, unless a valid publisher ID for the new pub_id is in the publishers table. Second, it ensures that no changes are made to a pub_id value in the publishers table without consideration of the referencing values in the titles table. It can do this in two ways. It can restrict changes to the publishers table so that a publisher can't be deleted or a pub_id value can't be changed if any titles in the titles table reference that publisher. Alternatively, it can cascade the changes through the titles table. So, if you were to delete a publisher, all rows in titles that reference that publisher would also be deleted. If you were to update a pub_id, all matching pub_id values in titles would be updated to the same value.
The third type of data integrity is domain integrity, in which individual data values must meet certain criteria. SQL Server makes sure that any data entered matches the type and range of the specified datatype. For example, it prohibits NULL values from being entered in a column unless the column explicitly allows NULLs. SQL Server supports a wide range of datatypes, resulting in great flexibility and efficient storage. It also supports the definition of CHECK constraints to define conditions that the data in a column must meet.
Datatypes
SQL Server datatypes provide the simplest form of data integrity by restricting the types of information (for example, characters, numbers, or dates) that can be stored in the columns of the database tables. You can also design your own datatypes (user-defined datatypes) to supplement those supplied by the system. For example, you can define a state_code datatype as two characters (CHAR(2)); SQL Server will then accept only two-character state codes. You can use a user-defined datatype to define columns in any table. An advantage of user-defined datatypes is that you can bind rules and defaults to them for use in multiple tables, eliminating the need to include these types of checks in the front-end application.
CHECK Constraints and Rules
CHECK constraints and rules are integrity constraints that go beyond those implied by a column's datatype. When a user enters a value, SQL Server checks that value against any CHECK constraint or rule created for the specified column to ensure that only values that adhere to the definition of the constraint or rule are accepted.
Although CHECK constraints and rules are essentially equivalent in functionality, CHECK constraints are easier to use and provide more flexibility. CHECK constraints are the preferred mechanism for restricting values in a column; SQL Server provides rules primarily as backward compatibility feature. A CHECK constraint can be conveniently defined when a column is defined, it can be defined on multiple columns, and it has access to all of SQL Server's built-in functions. A rule, however, must be defined and then bound separately to a single column or user-defined datatype, and it has access only to built-in functions that don't reference database objects.
Both CHECK constraints and rules原文请找腾讯752018766辣-文^论^文.网
http://www.751com.cn advantage of CHECK constraints is that they can depend on either the value of another column or columns in the row or on the value returned by one of the built-in functions. A rule can't reference other fields. As an example of applying a CHECK constraint or rule, a database containing information on senior citizens could have the CHECK constraint or the rule "age column must contain a value between 65 and 120 years." A birth certificate database could require that the date in the birth_date column be some date prior to the current date.
Defaults
Defaults allow you to specify a value that SQL Server inserts if no value is explicitly entered in a particular field. For example, you can set the current date as the default value for an order_date field in a customer order record. Then, if a user or front-end application doesn't make an entry in the order_date field, SQL Server automatically inserts the current date. You can also use the keyword DEFAULT as a placeholder in an INSERT or UPDATE statement, which instructs SQL Server to set the value to the declared default value.
Triggers
Triggers are a special type of stored procedure. Stored procedures can be executed only when explicitly called; triggers are automatically invoked, or triggered, by SQL Server, and this is their main advantage. Triggers are associated with particular pieces of data and are called automatically whenever an a上一页 [1] [2] [3] [4] 下一页
数据库外文文献及翻译 第2页下载如图片无法显示或论文不完整,请联系qq752018766