Chapter 14. Creating Views

In This Chapter

  • Planning views wisely

  • Creating views with Management Studio

  • Updating through views

  • Performance and views

  • Nesting views

A view is the saved text of a SQL select statement that may be referenced as a data source within a query, similar to how a subquery can be used as a data source—no more, no less. A view can't be executed by itself; it must be used within a query.

Views are sometimes described as "virtual tables." This isn't a completely accurate description because views don't store any data. Like any other SQL query, views merely refer to the data stored in tables.

With this in mind, it's important to fully understand how views work, and the pros and cons of using views, and the best place to use views within your project architecture.

Why Use Views?

While there are several opinions on the use of views, ranging from total abstinence to overuse, the Information Architecture Principle (from Chapter 1) can serve as a guide for the most appropriate use of views. The principle states that "information . . . must be . . . made readily available in a usable format for daily operations and analysis by individuals, groups, and processes . . ."

Presenting data in a more useable format is precisely what views do best.

Data within a normalized RDBMS is rarely organized in a readily available format. Building ad hoc queries that extract the correct information from a normalized database is a challenge for most end-users. A well-written view can hide the complexity ...

Get SQL Server™ 2005 Bible now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.