Академический Документы
Профессиональный Документы
Культура Документы
Module Overview
Selecting Data Types
Designing Database Tables
Designing Data Integrity
Integer
Integer versus
versus GUID
GUID primary
primary keys
keys
Fixed
Fixed versus
versus variable
variable length
length columns
columns
VARCHAR
VARCHAR (MAX),
(MAX), NVARCHAR
NVARCHAR (MAX),
(MAX), and
and VARBINARY
VARBINARY (MAX)
(MAX) data
data types
types
Character
Character column
column collations
collations and
and Unicode
Unicode and
and non-Unicode
non-Unicode data
data types
types
Transact-SQL
Transact-SQL user-defined
user-defined data
data types
types
Datetime2
Datetime2 //
Datetimeoffset
Datetimeoffset
Date:
Date: From
From 01/01/0001
01/01/0001 to
to 12/31/9999
12/31/9999
Date:
Date: No
No time
time component
component
Time:
Time: Based
Based on
on 24
24 hour
hour clock,
clock, NO
NO date
date
component
component
Time:
Time: Accurate
Accurate to
to 100
100 ns
ns
Hierarchyid
Hierarchyid
FILESTREAM
FILESTREAM
To
To create
create tables
tables with
with aa hierarchical
hierarchical
When
When aa table
table contains
contains aa FILESTREAM
FILESTREAM
structure
structure
To
To query
query and
and perform
perform work
work with
with
hierarchical
data
by
using
T-SQL
hierarchical data by using T-SQL
Same
Same date
date precision
precision as
as date
date
Same
Same time
time precision
precision as
as time
time
DateTimeOffset
DateTimeOffset is
is time
time zone
zone aware
aware
column
column
When
When objects
objects are
are larger
larger than
than 11 MB
MB
Where
Where fast
fast read
read access
access is
is important
important
Where
Where you
you use
use aa middle
middle tier
tier
Avoid
Avoid excessively
excessively complex
complex data
data types
types
Consider
Consider the
the overhead
overhead of
of row-by-row
row-by-row processing
processing
Consider
Consider the
the risks
risks of
of tightly
tightly coupling
coupling aa CLR
CLR user-defined
user-defined data
data types
types
and
and the
the database
database
Geometry
Data Type
Geography Data
Type
location
location and
and shape
shape of
of geometric
geometric
objects
objects
Can
Can be
be of
of two
two types
types including
including
geometry
geometry and
and geography
geography data
data types
types
Implemented
Implemented as
as .NET
.NET common
common
language
language runtime
runtime data
data types
types in
in SQL
SQL
Server
Server
Supports
Supports eleven
eleven spatial
spatial data
data objects,
objects,
or
or instance
instance types
types
Use
Use the
the XML
XML data
data type
type for
for data
data that
that is
is not
not frequently
frequently updated
updated
Use
Use typed
typed XML
XML columns
columns
Use
Use the
the XML
XML data
data type
type for
for data
data that
that is
is not
not relationally
relationally structured
structured
Use
Use the
the XML
XML data
data type
type for
for configuration
configuration information
information
< xml >
Use
Use the
the XML
XML data
data type
type for
for data
data with
with recursive
recursive structures
structures
Data Overflow
Capacity Planning
Properties
Properties of
of Sparse
Sparse Columns
Columns
The
The SQL
SQL Server
Server Database
Database Engine
Engine uses
uses the
the SPARSE
SPARSE keyword
keyword in
in aa column
column
definition
definition to
to optimize
optimize the
the storage
storage of
of values
values in
in that
that column.
column.
Catalog
Catalog views
views for
for aa table
table that
that has
has sparse
sparse columns
columns are
are the
the same
same as
as for
for aa typical
typical
table.
table.
The
The COLUMNS_UPDATED
COLUMNS_UPDATED function
function returns
returns aa varbinary
varbinary value
value to
to indicate
indicate all
all the
the
columns
columns that
that were
were updated
updated during
during aa DML
DML action.
action.
Data
Data types
types that
that you
you cannot
cannot specify
specify as
as sparse
sparse are
are geography,
geography, geometry,
geometry, image,
image, ntext,
ntext, text,
text,
timestamp,
timestamp, and
and user-defined
user-defined data
data types.
types.
Usage
Persisted
Usage
of of
Persisted
Computed
Computed
Usage
of Computed
Columns
Exceptions
in Columns
Column
Columns
Data
Avoid
the overhead
of to
complex
functions
in computed
columns
Use
persisted
computed
computed
columns
columns
derive results
for performance
from
other columns
Avoid persisted computed columns on active data
Computed
Protect against numeric overflow
andColumns
divide by zero errors
Usage of Computed
Columns
Exceptions in Column
Data
(HireDate int
NOT NULL...)
(CONSTRAINT Qty
DEFAULT 0...)
CONSTRAINT
chkQty CHECK
(Amount > 0)...)
Check
Constraint
Bound
Rules
Specify
Specify cascading
cascading levels
levels and
and options
options
Use
Use ANSI-standard
ANSI-standard options
options
ON DELETE
Use
Use triggers
triggers to
to enforce
enforce referential
referential integrity
integrity
Use
Use table-level
table-level CHECK
CHECK constraints
constraints
Check Constraint
Use
Use DDL
DDL triggers
triggers for
for auditing
auditing
Use
Use DDL
DDL triggers
triggers to
to support
support security
security
Use
Use DDL
DDL triggers
triggers to
to prevent
prevent database
database changes
changes
Use
Use DDL
DDL triggers
triggers with
with transactions
transactions
Use
Use DDL
DDL triggers
triggers scope
scope to
to control
control database
database operations
operations or
or objects
objects that
that
activates
activates the
the trigger
trigger
Avoid
Avoid creating
creating DDL
DDL Trigger
Trigger on
on both
both CREATE_SCHEMA
CREATE_SCHEMA and
and
CREATE_TABLE
CREATE_TABLE event
event
Use
Use value()
value() instead
instead of
of query()
query() when
when querying
querying data
data returned
returned from
from
EVENTDATA
EVENTDATA
Question:
What are the best options for column data types and data
constraints?
Database Model
Logon Information
User name
Administrator
Password
Pa$$w0rd
Lab Scenario
You are a lead database designer at QuantamCorp. You are working on the Human
Resources Vacation and Sick Leave Enhancement (HR VASE) project that is designed to
enhance the current HR system of your organization. This system is based on the
QuantamCorp2008 sample database in SQL Server 2008.
The main goals of the HR VASE project are as follows:
Provide managers with current and historical information about employee vacation and
sick-leave data.
Provide permission to individual employees to view their vacation and sick-leave
balances.
Provide permission to selected employees in the HR department to view and update
earlier.
Lab Review
Can you explain the purpose of creating naming standards and
not exist?