SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
Module 4
     Designing and
Implementing Views
Module Overview
• Introduction to Views

• Creating and Managing Views

• Performance Considerations for Views
Lesson 1: Introduction to Views
• What is a View?

• Types of Views

• Advantages of Views

• Working with System Views

• Dynamic Management Views

• Demonstration 1A: System and Dynamic Management
 Views
What is a View?
• A view is a database object referenced like a table
• A view is like a SELECT query with a name

    Employee (table)
    EmployeeID    LastName      FirstName      Title           BirthDate   …

       287       Mensa-Annan      Tete          Mr.            3/2/1984    …
       288             Abbas      Syed          Mr.            4/5/1976    …

       289         Valdez        Rachel        NULL            9/8/1973    …



                                EmployeeList (view)
                   EmployeeID    LastName             FirstName
                          287   Mensa-Annan             Tete
                          288      Abbas                Syed

                          289      Valdez              Rachel
Types of Views

• Standard views
     Combine data from one or more base tables into a new virtual
      table

• System Views
     Provide state information for SQL Server and catalogs

• Indexed views
     View that has been computed and stored. You index a view by
      creating a unique clustered index on it

• Partitioned views
     Joins horizontally partitioned data from a set of tables across one
      or more servers
Advantages of Views


• Focus the data for a user

• Mask database complexity

• Simplify management of user permissions


• Organize data for export to other applications


• Provide backward compatibility


• Structure data for reporting applications
Working with System Views

There are several types of system views:
• Catalog Views
     Return information used by the SQL Server Database Engine

• Compatibility Views
     Many system tables available in earlier versions are now available
      as system views

• Information Schema Views
     Provide catalog information as defined in the ISO standard for the
      INFORMATION_SCHEMA.
Dynamic Management Views


• Return server state information

• Named like sys.dm_*


• Some are implemented as functions, some as views


• Monitor server health


• Diagnose problems, tune performance
Demonstration 1A: System and Dynamic
Management Views
In this demonstration, you will see how to:
• Query system views

• Query dynamic management views
Lesson 2: Creating and Managing Views
• Creating Views

• Dropping Views

• Altering Views

• Ownership Chains and Views

• Sources of Information about Views

• Updatable Views

• Obfuscating Views Definitions

• Demonstration 2A: Implementing Views
Creating Views

• Use the CREATE VIEW Transact-SQL statement:

 CREATE VIEW HumanResources.EmployeeList
 AS
 SELECT EmployeeID, LastName, FirstName
 FROM HumanResources.Employee;



• Restrictions on creating views:
     Cannot nest more than 32 levels deep
     Cannot use ORDER BY without TOP
Dropping Views


• Drop by using the DROP VIEW Transact-SQL statement:


      DROP VIEW HumanResources.EmployeeList;



• Also drops all permissions associated with the view

• Multiple views can be dropped in a single statement
     Comma-delimited list of views
Altering Views


• Alter by using the ALTER VIEW Transact-SQL statement:


 ALTER VIEW HumanResources.EmployeeList
 AS
 SELECT EmployeeID, LastName, FirstName, PostalCode
 FROM HumanResources.Employee;

• Replaces the definition of a view

• Does not alter permissions associated with the view
Ownership Chains and Views
Sources of Information About Views

     SQL Server Management Studio
                 Source                            Information
                                     List of views in database
    Object Explorer                  Access to columns, triggers, indexes,
                                     and statistics defined on views
    View Properties dialog box       Properties of individual views

     Transact-SQL
                 Source                            Information
   sys.views                         List of views in database
                                     Function that returns definition of non-
   OBJECT_DEFINITION()
                                     encrypted views
                                     Objects (including views) that depend
   sys.sql_expression_dependencies
                                     on other objects
Updatable Views

• Views do not maintain a separate copy of data

• Updates to views modify the base tables

• Updates are restricted by using the WITH CHECK OPTION




• Restrictions:

• Cannot affect more than one base table

• Cannot modify columns derived from functions or expressions

• Cannot modify columns affected by GROUP BY, HAVING, or
 DISTINCT clauses
Obfuscating View Definitions

• WITH ENCRYPTION clause

• Encrypts view definition stored in SQL Server

• Protects view creation logic to a limited extent

• Generally not recommended

  CREATE VIEW HumanResources.EmployeeList
  WITH ENCRYPTION
  AS
  SELECT EmployeeID, LastName, FirstName
  FROM HumanResources.Employee;




Use WITH ENCRYPTION on ALTER VIEW to retain encryption
Demonstration 2A: Implementing Views
In this demonstration, you will see how to:
• Create a view

• Query a view

• Query the definition of a view

• Use the WITH ENCRYPTION option

• Drop a view

• Generate a script for an existing view
Lesson 3: Performance Considerations for Views
• Views and Dynamic Resolution

• Nested View Considerations

• Partitioned Views

• Demonstration 3A: Views and Performance
Views and Dynamic Resolution

• Dynamic resolution in view optimization can assist
 performance

• SQL Server does not retrieve data that it doesn’t need

• Single query plan for both query and view

• Query plans do not show standard views

• SELECT * needs special consideration in views

     Should be avoided
Nested View Considerations

• Views can provide a convenient layer of abstraction in
 coding

• Views can be nested up to 32 levels

• Nested views can hide code complexity

     More difficult to troubleshoot performance issues

     More difficult to understand code complexity
Partitioned Views

  Joins partitioned data from set of tables across servers


SQLServerNorth.Sales.Sale     SQLServerSouth.Sales.Sale




                                CREATE VIEW Sales.AllSales AS
                                SELECT * FROM
                                SQLServerNorth.Sales.Sale
                     vSales
                                UNION ALL
                                SELECT *
                                FROM SQLServerSouth.Sales.Sale;
Demonstration 3A: Views and Performance
In this demonstration, you will see how:
• Views are eliminated in query plans

• Views are expanded and integrated into the outer query
 before being optimized
Lab 4: Designing and Implementing Views
• Exercise 1: Design, Implement and Test the WebStock
 Views
• Exercise 2: Design and Implement the Contacts View

• Challenge Exercise 3: Modify the AvailableModels View
 (only if time permits)



Logon information
Virtual machine      623XB-MIA-SQL

User name            AdventureWorksAdministrator
Password             Pa$$w0rd


Estimated time: 45 minutes
Lab Scenario
A new web-based stock promotion system is being rolled
out. Your manager is very concerned about providing access
from the web-based system directly to the tables in your
database. She has requested you to design some views that
the web-based system could connect to instead.
Details of organizational contacts are held in a number of
tables. The relationship management system being used by
the account management team needs to be able to gain
access to these contacts. However, they need a single view
that comprises all contacts. You need to design, implement
and test the required view.
Finally, if you have time, a request has been received from
the new Marketing team that the catalog description of the
product models should be added to the AvailableModels
view. They would appreciate you modifying the view to
provide this additional column.
Lab Review

• What considerations are there for views that involve
 multiple tables?

• What is required for columns in views that are created
 from expressions?
Module Review and Takeaways
• Review Questions

• Best Practices

Weitere ähnliche Inhalte

Was ist angesagt?

01 qmds2005 session01
01 qmds2005 session0101 qmds2005 session01
01 qmds2005 session01Niit Care
 
Oracle Data Redaction
Oracle Data RedactionOracle Data Redaction
Oracle Data RedactionIvica Arsov
 
Views and security
Views and securityViews and security
Views and securityfarhan amjad
 
Create column store index on all supported tables in sql server 2014 copy
Create column store index on all supported tables in sql server 2014    copyCreate column store index on all supported tables in sql server 2014    copy
Create column store index on all supported tables in sql server 2014 copyMustafa EL-Masry
 
Sql Server 2008 Enhancements
Sql Server 2008 EnhancementsSql Server 2008 Enhancements
Sql Server 2008 Enhancementskobico10
 
AppSense EM 8.5 Deep Dive
AppSense EM 8.5 Deep DiveAppSense EM 8.5 Deep Dive
AppSense EM 8.5 Deep DiveDave Allen
 
AppSense Environment Manager 8.5 Beta
AppSense Environment Manager 8.5 BetaAppSense Environment Manager 8.5 Beta
AppSense Environment Manager 8.5 BetaDave Allen
 
Copy Of Mysql Datadictionary
Copy Of Mysql DatadictionaryCopy Of Mysql Datadictionary
Copy Of Mysql DatadictionaryGolak Sarangi
 
SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2Dan D'Urso
 
09 qmds2005 session13
09 qmds2005 session1309 qmds2005 session13
09 qmds2005 session13Niit Care
 
Controlling User Access -Data base
Controlling User Access -Data baseControlling User Access -Data base
Controlling User Access -Data baseSalman Memon
 
SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1Dan D'Urso
 
Trainmesfottech - Sql Server DBA Training Course Content
Trainmesfottech - Sql Server DBA Training Course ContentTrainmesfottech - Sql Server DBA Training Course Content
Trainmesfottech - Sql Server DBA Training Course ContentTrainmesofttech
 
Mirroring in SQL Server 2012 R2
Mirroring in SQL Server 2012 R2Mirroring in SQL Server 2012 R2
Mirroring in SQL Server 2012 R2Mahesh Dahal
 
Including Constraints -Oracle Data base
Including Constraints -Oracle Data base Including Constraints -Oracle Data base
Including Constraints -Oracle Data base Salman Memon
 

Was ist angesagt? (19)

01 qmds2005 session01
01 qmds2005 session0101 qmds2005 session01
01 qmds2005 session01
 
Oracle Data Redaction
Oracle Data RedactionOracle Data Redaction
Oracle Data Redaction
 
Views and security
Views and securityViews and security
Views and security
 
Create column store index on all supported tables in sql server 2014 copy
Create column store index on all supported tables in sql server 2014    copyCreate column store index on all supported tables in sql server 2014    copy
Create column store index on all supported tables in sql server 2014 copy
 
Oracle SQL Training in Chennai, Tambaram
Oracle SQL Training in Chennai, TambaramOracle SQL Training in Chennai, Tambaram
Oracle SQL Training in Chennai, Tambaram
 
Sql Server 2008 Enhancements
Sql Server 2008 EnhancementsSql Server 2008 Enhancements
Sql Server 2008 Enhancements
 
AppSense EM 8.5 Deep Dive
AppSense EM 8.5 Deep DiveAppSense EM 8.5 Deep Dive
AppSense EM 8.5 Deep Dive
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
AppSense Environment Manager 8.5 Beta
AppSense Environment Manager 8.5 BetaAppSense Environment Manager 8.5 Beta
AppSense Environment Manager 8.5 Beta
 
Copy Of Mysql Datadictionary
Copy Of Mysql DatadictionaryCopy Of Mysql Datadictionary
Copy Of Mysql Datadictionary
 
FREE Sql Server syllabus
FREE Sql Server syllabusFREE Sql Server syllabus
FREE Sql Server syllabus
 
SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2SQL302 Intermediate SQL Workshop 2
SQL302 Intermediate SQL Workshop 2
 
09 qmds2005 session13
09 qmds2005 session1309 qmds2005 session13
09 qmds2005 session13
 
Controlling User Access -Data base
Controlling User Access -Data baseControlling User Access -Data base
Controlling User Access -Data base
 
SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1SQL302 Intermediate SQL Workshop 1
SQL302 Intermediate SQL Workshop 1
 
Trainmesfottech - Sql Server DBA Training Course Content
Trainmesfottech - Sql Server DBA Training Course ContentTrainmesfottech - Sql Server DBA Training Course Content
Trainmesfottech - Sql Server DBA Training Course Content
 
Mirroring in SQL Server 2012 R2
Mirroring in SQL Server 2012 R2Mirroring in SQL Server 2012 R2
Mirroring in SQL Server 2012 R2
 
Introduction to Mysql
Introduction to MysqlIntroduction to Mysql
Introduction to Mysql
 
Including Constraints -Oracle Data base
Including Constraints -Oracle Data base Including Constraints -Oracle Data base
Including Constraints -Oracle Data base
 

Ähnlich wie 6232 b 04

Sage 300 ERP: Technical Tour of Diagnostic Tools
Sage 300 ERP: Technical Tour of Diagnostic ToolsSage 300 ERP: Technical Tour of Diagnostic Tools
Sage 300 ERP: Technical Tour of Diagnostic ToolsSage 300 ERP CS
 
Creating other schema objects
Creating other schema objectsCreating other schema objects
Creating other schema objectsSyed Zaid Irshad
 
Power View: Analysis and Visualization for Your Application’s Data
Power View: Analysis and Visualization for Your Application’s DataPower View: Analysis and Visualization for Your Application’s Data
Power View: Analysis and Visualization for Your Application’s DataAndrew Brust
 
New features of sql server 2016 bi features
New features of sql server 2016 bi featuresNew features of sql server 2016 bi features
New features of sql server 2016 bi featuresChris Testa-O'Neill
 
Solving the DB2 LUW Administration Dilemma
Solving the DB2 LUW Administration DilemmaSolving the DB2 LUW Administration Dilemma
Solving the DB2 LUW Administration DilemmaRandy Goering
 
Solving the DB2 LUW Administration Dilemma
Solving the DB2 LUW Administration DilemmaSolving the DB2 LUW Administration Dilemma
Solving the DB2 LUW Administration DilemmaRandy Goering
 
Tech-Spark: Azure SQL Databases
Tech-Spark: Azure SQL DatabasesTech-Spark: Azure SQL Databases
Tech-Spark: Azure SQL DatabasesRalph Attard
 
World2016_T5_S5_SQLServerFunctionalOverview
World2016_T5_S5_SQLServerFunctionalOverviewWorld2016_T5_S5_SQLServerFunctionalOverview
World2016_T5_S5_SQLServerFunctionalOverviewFarah Omer
 
A Primer To Sybase Iq Development July 13
A Primer To Sybase Iq Development July 13A Primer To Sybase Iq Development July 13
A Primer To Sybase Iq Development July 13sparkwan
 
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn vbds
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn  vbdsfoodmunch 2.pptx hdshid hdbfhdbfhkd vcn  vbds
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn vbdsputtipavan23022023
 
Session 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian MalbeufSession 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian MalbeufCTE Solutions Inc.
 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL IISankhya_Analytics
 
Cloud architectural patterns and Microsoft Azure tools
Cloud architectural patterns and Microsoft Azure toolsCloud architectural patterns and Microsoft Azure tools
Cloud architectural patterns and Microsoft Azure toolsPushkar Chivate
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptxKareemBullard1
 
Oracle Enterprise Manager 12c: updates and upgrades.
Oracle Enterprise Manager 12c: updates and upgrades.Oracle Enterprise Manager 12c: updates and upgrades.
Oracle Enterprise Manager 12c: updates and upgrades.Rolta
 

Ähnlich wie 6232 b 04 (20)

SQL Server 2016 BI updates
SQL Server 2016 BI updatesSQL Server 2016 BI updates
SQL Server 2016 BI updates
 
Sage 300 ERP: Technical Tour of Diagnostic Tools
Sage 300 ERP: Technical Tour of Diagnostic ToolsSage 300 ERP: Technical Tour of Diagnostic Tools
Sage 300 ERP: Technical Tour of Diagnostic Tools
 
Partially Contained Databases
Partially Contained DatabasesPartially Contained Databases
Partially Contained Databases
 
Creating other schema objects
Creating other schema objectsCreating other schema objects
Creating other schema objects
 
Power View: Analysis and Visualization for Your Application’s Data
Power View: Analysis and Visualization for Your Application’s DataPower View: Analysis and Visualization for Your Application’s Data
Power View: Analysis and Visualization for Your Application’s Data
 
New features of sql server 2016 bi features
New features of sql server 2016 bi featuresNew features of sql server 2016 bi features
New features of sql server 2016 bi features
 
Solving the DB2 LUW Administration Dilemma
Solving the DB2 LUW Administration DilemmaSolving the DB2 LUW Administration Dilemma
Solving the DB2 LUW Administration Dilemma
 
Solving the DB2 LUW Administration Dilemma
Solving the DB2 LUW Administration DilemmaSolving the DB2 LUW Administration Dilemma
Solving the DB2 LUW Administration Dilemma
 
Tech-Spark: Azure SQL Databases
Tech-Spark: Azure SQL DatabasesTech-Spark: Azure SQL Databases
Tech-Spark: Azure SQL Databases
 
World2016_T5_S5_SQLServerFunctionalOverview
World2016_T5_S5_SQLServerFunctionalOverviewWorld2016_T5_S5_SQLServerFunctionalOverview
World2016_T5_S5_SQLServerFunctionalOverview
 
A Primer To Sybase Iq Development July 13
A Primer To Sybase Iq Development July 13A Primer To Sybase Iq Development July 13
A Primer To Sybase Iq Development July 13
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
 
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn vbds
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn  vbdsfoodmunch 2.pptx hdshid hdbfhdbfhkd vcn  vbds
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn vbds
 
Session 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian MalbeufSession 2: SQL Server 2012 with Christian Malbeuf
Session 2: SQL Server 2012 with Christian Malbeuf
 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL II
 
Cloud architectural patterns and Microsoft Azure tools
Cloud architectural patterns and Microsoft Azure toolsCloud architectural patterns and Microsoft Azure tools
Cloud architectural patterns and Microsoft Azure tools
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
 
Oracle Enterprise Manager 12c: updates and upgrades.
Oracle Enterprise Manager 12c: updates and upgrades.Oracle Enterprise Manager 12c: updates and upgrades.
Oracle Enterprise Manager 12c: updates and upgrades.
 
Sql server basics
Sql server basicsSql server basics
Sql server basics
 
Manageability Enhancements of SQL Server 2012
Manageability Enhancements of SQL Server 2012Manageability Enhancements of SQL Server 2012
Manageability Enhancements of SQL Server 2012
 

6232 b 04

  • 1. Module 4 Designing and Implementing Views
  • 2. Module Overview • Introduction to Views • Creating and Managing Views • Performance Considerations for Views
  • 3. Lesson 1: Introduction to Views • What is a View? • Types of Views • Advantages of Views • Working with System Views • Dynamic Management Views • Demonstration 1A: System and Dynamic Management Views
  • 4. What is a View? • A view is a database object referenced like a table • A view is like a SELECT query with a name Employee (table) EmployeeID LastName FirstName Title BirthDate … 287 Mensa-Annan Tete Mr. 3/2/1984 … 288 Abbas Syed Mr. 4/5/1976 … 289 Valdez Rachel NULL 9/8/1973 … EmployeeList (view) EmployeeID LastName FirstName 287 Mensa-Annan Tete 288 Abbas Syed 289 Valdez Rachel
  • 5. Types of Views • Standard views  Combine data from one or more base tables into a new virtual table • System Views  Provide state information for SQL Server and catalogs • Indexed views  View that has been computed and stored. You index a view by creating a unique clustered index on it • Partitioned views  Joins horizontally partitioned data from a set of tables across one or more servers
  • 6. Advantages of Views • Focus the data for a user • Mask database complexity • Simplify management of user permissions • Organize data for export to other applications • Provide backward compatibility • Structure data for reporting applications
  • 7. Working with System Views There are several types of system views: • Catalog Views  Return information used by the SQL Server Database Engine • Compatibility Views  Many system tables available in earlier versions are now available as system views • Information Schema Views  Provide catalog information as defined in the ISO standard for the INFORMATION_SCHEMA.
  • 8. Dynamic Management Views • Return server state information • Named like sys.dm_* • Some are implemented as functions, some as views • Monitor server health • Diagnose problems, tune performance
  • 9. Demonstration 1A: System and Dynamic Management Views In this demonstration, you will see how to: • Query system views • Query dynamic management views
  • 10. Lesson 2: Creating and Managing Views • Creating Views • Dropping Views • Altering Views • Ownership Chains and Views • Sources of Information about Views • Updatable Views • Obfuscating Views Definitions • Demonstration 2A: Implementing Views
  • 11. Creating Views • Use the CREATE VIEW Transact-SQL statement: CREATE VIEW HumanResources.EmployeeList AS SELECT EmployeeID, LastName, FirstName FROM HumanResources.Employee; • Restrictions on creating views:  Cannot nest more than 32 levels deep  Cannot use ORDER BY without TOP
  • 12. Dropping Views • Drop by using the DROP VIEW Transact-SQL statement: DROP VIEW HumanResources.EmployeeList; • Also drops all permissions associated with the view • Multiple views can be dropped in a single statement  Comma-delimited list of views
  • 13. Altering Views • Alter by using the ALTER VIEW Transact-SQL statement: ALTER VIEW HumanResources.EmployeeList AS SELECT EmployeeID, LastName, FirstName, PostalCode FROM HumanResources.Employee; • Replaces the definition of a view • Does not alter permissions associated with the view
  • 15. Sources of Information About Views SQL Server Management Studio Source Information List of views in database Object Explorer Access to columns, triggers, indexes, and statistics defined on views View Properties dialog box Properties of individual views Transact-SQL Source Information sys.views List of views in database Function that returns definition of non- OBJECT_DEFINITION() encrypted views Objects (including views) that depend sys.sql_expression_dependencies on other objects
  • 16. Updatable Views • Views do not maintain a separate copy of data • Updates to views modify the base tables • Updates are restricted by using the WITH CHECK OPTION • Restrictions: • Cannot affect more than one base table • Cannot modify columns derived from functions or expressions • Cannot modify columns affected by GROUP BY, HAVING, or DISTINCT clauses
  • 17. Obfuscating View Definitions • WITH ENCRYPTION clause • Encrypts view definition stored in SQL Server • Protects view creation logic to a limited extent • Generally not recommended CREATE VIEW HumanResources.EmployeeList WITH ENCRYPTION AS SELECT EmployeeID, LastName, FirstName FROM HumanResources.Employee; Use WITH ENCRYPTION on ALTER VIEW to retain encryption
  • 18. Demonstration 2A: Implementing Views In this demonstration, you will see how to: • Create a view • Query a view • Query the definition of a view • Use the WITH ENCRYPTION option • Drop a view • Generate a script for an existing view
  • 19. Lesson 3: Performance Considerations for Views • Views and Dynamic Resolution • Nested View Considerations • Partitioned Views • Demonstration 3A: Views and Performance
  • 20. Views and Dynamic Resolution • Dynamic resolution in view optimization can assist performance • SQL Server does not retrieve data that it doesn’t need • Single query plan for both query and view • Query plans do not show standard views • SELECT * needs special consideration in views  Should be avoided
  • 21. Nested View Considerations • Views can provide a convenient layer of abstraction in coding • Views can be nested up to 32 levels • Nested views can hide code complexity  More difficult to troubleshoot performance issues  More difficult to understand code complexity
  • 22. Partitioned Views Joins partitioned data from set of tables across servers SQLServerNorth.Sales.Sale SQLServerSouth.Sales.Sale CREATE VIEW Sales.AllSales AS SELECT * FROM SQLServerNorth.Sales.Sale vSales UNION ALL SELECT * FROM SQLServerSouth.Sales.Sale;
  • 23. Demonstration 3A: Views and Performance In this demonstration, you will see how: • Views are eliminated in query plans • Views are expanded and integrated into the outer query before being optimized
  • 24. Lab 4: Designing and Implementing Views • Exercise 1: Design, Implement and Test the WebStock Views • Exercise 2: Design and Implement the Contacts View • Challenge Exercise 3: Modify the AvailableModels View (only if time permits) Logon information Virtual machine 623XB-MIA-SQL User name AdventureWorksAdministrator Password Pa$$w0rd Estimated time: 45 minutes
  • 25. Lab Scenario A new web-based stock promotion system is being rolled out. Your manager is very concerned about providing access from the web-based system directly to the tables in your database. She has requested you to design some views that the web-based system could connect to instead. Details of organizational contacts are held in a number of tables. The relationship management system being used by the account management team needs to be able to gain access to these contacts. However, they need a single view that comprises all contacts. You need to design, implement and test the required view. Finally, if you have time, a request has been received from the new Marketing team that the catalog description of the product models should be added to the AvailableModels view. They would appreciate you modifying the view to provide this additional column.
  • 26. Lab Review • What considerations are there for views that involve multiple tables? • What is required for columns in views that are created from expressions?
  • 27. Module Review and Takeaways • Review Questions • Best Practices