Datasheet

Chapter 1: Being Objective: Re-Examining Objects in SQL Server
more roles. Rights to perform certain actions in SQL Server can then be granted directly to a user or to a
role to which one or more users belong.
Rules
Rules and constraints provide restriction information about what can go into a table. If an updated or
inserted record violates a rule, then that insertion or update will be rejected. In addition, a rule can be
used to define a restriction on a user-defined data type. Unlike rules, constraints aren’t really objects unto
themselves but rather pieces of metadata describing a particular table.
While Microsoft has not stated a particular version for doing so, they continue to
warn that rules will be removed in a future release. Rules should be considered for
backward compatibility only and should be avoided in new development. You
should also begin phasing out any you already have in use in your database.
Defaults
There are two types of defaults. There is the default that is an object unto itself and the default that is not
really an object, but rather metadata describing a particular column in a table (in much the same way that
we have rules, which are objects, and constraints, which are not objects but metadata). They both serve
the same purpose. If, when inserting a record, you don’t provide the value of a column and that column
has a default defined, a value will be inserted automatically as defined in the default.
Much like rules, the form of default that is its own object should be treated as a
legacy object and avoided i n new development and actively removed from existing
code. Use of default constraints is, however, still very valid.
User-Defined Data Types
User-defined data types are extensions to the system-defined data types. The possibilities here are almost
endless, but you must keep backward compatibility in mind. Although SQL Server 2000 and earlier had
the idea of user-defined data types, they were really limited to different filtering of existing data types.
Since SQL Server 2005, we have the ability to bind .NET assemblies to our own data types, meaning we
can have a data type that stores (within reason) about anything we can store in a .NET object.
Careful with this! The data type that you’re working with is pretty fundamental to your data and its
storage. Although being able to define your own thing is very cool, recognize that it will almost cer-
tainly come with a large performance and most likely a security cost. Consider it carefully, be sure it’s
something you genuinely need, and then, as with everything like this, TEST, TEST, TEST!!!
Full-Text Catalogs
Full-text catalogs are mappings of data that speed the search for specific blocks of text within columns
that have full-text searching enabled. Although these objects are joined at the hip to the tables and
11