Datasheet

Users and Roles
These two go hand in hand. Users are pretty much the equivalent of logins. In short, this object repre-
sents an identifier for someone to log in to the SQL Server. Anyone logging into SQL Server has to map
(directly or indirectly depending on the security model in use) to a user. Users, in turn, belong to one or
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.
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 constraints which are objects, and rules, 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. We will
examine both types of defaults in Chapter 5.
User-Defined Data Types
User-defined data types are extensions to the system-defined data types. Beginning with this version of
SQL Server, the possibilities here are almost endless. 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. With SQL
Server 2005, you have the ability to bind .NET assemblies to your own data types, meaning you can
have a data type that stores (within reason) about anything you 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 cost. Consider it carefully, be sure it’s something you need, and
then, as with everything like this, TEST, TEST, TEST!!!
Much like rules, the form of default that is its own object should be treated as a legacy
object and avoided in new development. Use of default constraints is, however, still
very valid. See Chapter 5 for more information.
While Microsoft has not stated a particular version for doing so, they have warned
that rules will be removed in a future release. Rules should be considered for back-
ward compatibility only and should be avoided in new development. You may also
want to consider phasing out any you already have in use in your database.
10
Chapter 1
04_584340 ch01.qxp 10/18/06 2:11 PM Page 10