Tải bản đầy đủ (.pdf) (15 trang)

Apress - Pro SQL Server 2008 Relational Database Design and Implementation (2008)02

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (3.65 MB, 15 trang )

Character Strings
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
char[(length)]
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
varchar[(length)]
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620
varchar(max)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621
text
.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622
Unicode Character Strings: nchar, nvarchar, nvarchar(max), ntext
. . . . . 622
Binary Data
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623
binary[(length)]
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623
varbinary[(length)]
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624
varbinary(max)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624
image
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
Other Datatypes
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
rowversion (a.k.a. timestamp)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
uniqueidentifier
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626
cursor


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
sql_variant
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
Not Simply Scalar Datatypes
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633

INDEX
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635

CONTENTSxiv
8662FM.qxp 7/28/08 6:19 PM Page xiv
Foreword
D
atabase design is a passion that Louis and I share. This fall, I will be fortunate to share a stage with
my friend, Louis Davidson. We’re copresenting at DevLink in Louis’s hometown of Nashville and then
again at PASS in Seattle. Both times, we’ll discuss, debate, and celebrate the topic of database design
and how critical it is for any datacentric application.
Database design is part science and part art. There’s a science to normalization, but determining
the scope of the entity is an art form best learned from working with a broad repertoire of databases.
There’s a simple beauty to an elegant solution. Louis is more than an author or database designer
;
Louis is a master artisan, and in this book, you’ll discover hidden within the words a call to improve
your craft, to sculpt databases that stand the test of time, and to create vir
tual worlds of data that
enable developers to play their best game.
Database design is the foundation of every datacentric application. An elegant database design
makes the data obvious and easy to query and sets up the developer for success with efficient set-
based queries. But, no amount of code can compensate for a poor database design or add features

missing from the database. No role is more critical to any datacentric application than the role of
the data modeler. User interfaces come and go, but data lasts for generations of application lan-
guages, and today’s database schema errors will be cursed by programmers not yet born using
languages and tools not yet invented. It’s worth spending a little extra time to polish your database
design under the tutelage of my good friend, Louis.
So it’s with great pleasure that I welcome you to this third edition of Louis’s field guide to the
greatest job in the world of software.
Paul Nielsen
SQL Server MVP
xv
8662FM.qxp 7/28/08 6:19 PM Page xv
8662FM.qxp 7/28/08 6:19 PM Page xvi
About the Author

LOUIS DAVIDSON has over 15 years of experience as a corporate database
developer and architect. Currently, he is the data architect for the Christ-
ian Broadcasting Network and NorthStar Studios in Nashville, Tennessee.
Nearly all of Louis’s professional experience has been with Microsoft SQL
Server, from the early days to the latest version currently in beta. Louis has
been the principal author on four editions of a book on database design.
Louis’s primary areas of interest are database architecture and coding in
T-SQL, and he has experience designing many databases and writing
thousands of stored procedures and triggers through the years.
About the Contributing Authors

KEVIN KLINE is the technical strategy manager for SQL Server solutions at
Quest Software. A Microsoft SQL Server MVP since 2004, Kevin is a founding
board member and past president of the international Professional Associa-
tion for SQL Server (PASS). He has written or cowritten several books
including

SQL in a Nutshell (O’Reilly, 2004), Pro SQL Server 2005 Database
Design and Optimization
(Apress, 2006), and Database Benchmarking:
Practical Methods for Oracle & SQL Server
(Rampant, 2007). Kevin contributes
to
SQL Server Magazine and Database Trends and Applications and blogs at
SQLBlog.com and SQLMag.com. Kevin is also a top-rated speaker at confer-
ences worldwide, such as Microsoft Tech Ed, the PASS Community Summit, Microsoft IT Forum,
DevTeach, and SQL Connections, and has been active in the IT industry since 1986.

SCO
TT KLEIN
is an independent consultant with a passion for all things
SQL Server, .NET, and XML. He is the author of several books, including
Professional SQL Server 2005 XML (Wrox, 2006) and Professional LINQ (Wrox,
2008), and he wr
ites the biw
eekly feature article for the
SQL P
ASS Community
Connector
. H
e has also contr
ibuted ar
ticles for sev
er
al w
eb sites, including
Wrox (

) and TopXML (). He fre-
quently speaks to SQL Server and .NET user groups around Florida. Scott lives
in
W
ellington, Florida, and when he is not sitting in front of a computer, he
can be found hanging out with his family or aboard his Yamaha at the local
motocross track. He can be reached at


KURT WINDISCH is the applications supervisor for the internal IT department
at Levi, R
ay, and Shoup, Inc., a global provider of technology solutions with
headquarters in Springfield, Illinois. He has more than 17 years of experience
in the IT industry. He spent five years serving on the board of directors for the
Professional Association for SQL Server, has written for several SQL Server
magazines
, and has pr
esented at confer
ences internationally on the topic of
database programming with SQL Server.
xvii
8662FM.qxp 7/28/08 6:19 PM Page xvii
8662FM.qxp 7/28/08 6:19 PM Page xviii
About the Technical Reviewers

WAYNE SNYDER is recognized worldwide as a SQL Server expert and Microsoft Most Valued
Professional (MVP), and he has over 25 years of experience in project management, database
administration, software design, performance measurement, and capacity planning. He is a
sought-after speaker, consultant, writer, and trainer. Wayne is the current president of the
Professional Association for SQL Server (PASS) (

www.sqlpass.org) and a managing consultant for
Mariner, a business intelligence company (
www.mariner-usa.com). He also plays keyboard for a
regional cover band named SoundBarrier (
www.soundbarrierband.com).

EVAN TERRY is a lead consultant working at The Clegg Company, specializing in data modeling,
data quality, and information management. His past and current clients include the State of Idaho;
Albertsons; American Honda Motors; and Toyota Motor Sales, USA. He is the coauthor of Apress’s
Beginning R
elational Data Modeling
(2005) and was a presenter at the 2006 and 2007 IAIDQ confer
-
ences and at the 2008 DAMA International Conference on the subject of data quality. He can be
reached at


DON WATTERS is a Staff Software Engineer at the Walt Disney Internet Group in Seattle, Washington.
He has been working on Microsoft SQL Server products since version 6.5, and has over 10 years of
experience with the product. He has extensive administrative and developer experience with very
large OLTP and OLAP systems and enjoys learning and applying his knowledge to new and interest-
ing database challenges. In his free time, Don enjoys spending time with his children, playing music
and video games, and of course, studying all things related to Microsoft SQL Server. He can be
reached at

xix
8662FM.qxp 7/28/08 6:19 PM Page xix

×