Focusing on Specific Data

Views allow users or developers to focus on the specific data elements they need to work with. Tables that contain hundreds of columns or columns that have limited value for the end user can be filtered with a view such that only the relevant data elements are returned.

The HumanResources.vEmployee view in the AdventureWorks2012 database is a good example of a view that focuses on specific data and simplifies data access. The view definition follows:

CREATE VIEW [HumanResources].[vEmployee]ASSELECT    e.[BusinessEntityID]    ,p.[Title]    ,p.[FirstName]    ,p.[MiddleName]    ,p.[LastName]    ,p.[Suffix]    ,e.[JobTitle]    ,pp.[PhoneNumber]    ,pnt.[Name] AS [PhoneNumberType]    ,ea.[EmailAddress] ...

Get Microsoft® SQL Server 2012 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.