Professional Documents
Culture Documents
What Is Metadata?
Definition: Metadata is Data about Data. Adds Context to Data Hides Complexity From End Users Used in Determination of Data Types Reveals the Structure & Relationships Between Data Determines Changes in Data and What Changes Were
Made Data
Compatibility Views
Applications developed with previous versions of SQL Server
Compatibility views are provided for backward compatibility Compatibility views should be used for backward compatibility
only
event_notifications
triggers procedures foreign_key_columns
-413
-412 -411 -410
V
V V V
4
4 4 4
0
0 0 0
0
0 0 0
Name
Type_desc
USER_TABLE USER_TABLE USER_TABLE
Name
Server metadata.
Information Schema
TABLE_NAME
Provide an easy method for monitoring the internal state Provide information for a wide variety of categories
Index
I/O
dm_db_index_usage_stats
dm_io_pending_io_requests
dm_db_missing_index_columns
dm_io_virtual_file_stats
Operating System
dm_os_sys_info
SELECT COLUMNPROPERTY( OBJECT_ID('Person.Contact'), 'LastName', 'PRECISION') AS 'Column Length'; EXEC sp_columns @table_name = N'Department', @table_owner = N'HumanResources';
Functions
What Is XML?
Definition: The Extensible Markup Language (XML) is an open standard recommended by W3C for creating custom markup languages.
<people> <person> <first_name>Robert</first_name> <last_name>Frost</last_name> </person> <person> <first_name>Frank</first_name> <last_name>Baker</last_name> </person> </people>
XML
Tag based. Tags are self descriptive. Designers are free to create their own XML structures and tags to accommodate their data. The XML standard does not define the structures or the content but only the format.
XML
The OpenXML function provides the ability to deserialize XML into a rowset view. This rowset can then be queried as relational data.
XML
XQuery support allows query based interaction with data stored in XML format.
XML
XML Schema Collections provide the ability to define XML schemas for typed XML storage.
XML
The XML data type supports five methods for interacting with the data that it contains Accepts XQuery statements to retrieve elements of Query the XML data Value Exists Modify Nodes Retrieves a value of SQL type from an XML instance Determines if an XQuery statement returns results Is used to specify XML data modification update statements Splits XML into multiple rows
<Cust CustomerID="1" CustomerType="S"> <OrderHeader CustomerID="1" SalesOrderID="43860" <OrderHeader CustomerID="1" SalesOrderID="44501" <OrderHeader CustomerID="1" SalesOrderID="45283" <OrderHeader CustomerID="1" SalesOrderID="46042" </Cust>
SELECT Instructions.query(' declare namespace AWMI="http://schemas.microsoft.com /sqlserver/2004/07/adventureworks/ProductModelManuInstructions"; for $T in //AWMI:tool let $L := //AWMI:Location[.//AWMI:tool[.=data($T)]] return <tool desc="{data($T)}" Locations="{data($L/@LocationID)}"/> ') as Result FROM Production.ProductModel where ProductModelID=7
Use Cases
Exposing data for advanced web site searches
Results
Query Full-Text Index Data Table
Query Processor
Use sp_fulltext_table
Add required column(s) to the index Use sp_fulltext_column Activate and set population options for index
Use sp_fulltext_table
Design and build queries using full-text query functions and predicates according to business requirements
Full-Text Search
Results: We had to run in gym class The politician decided to run for office My car is not running He had to rest after he ran a mile Doctors say running is a healthy hobby
Word-breaking: vital, safety, components Stemming: vital, safe, safety, components List of expansions: vital, important, safe, safety, components, parts
Full-Text Functions
SELECT Product.ProdID, Product.Name, Prod.Desc, Keys.Rank FROM dbo.Product INNER JOIN FREETEXTTABLE(dbo.Product, Desc, safety harness',LANGUAGE 'English',2) AS Keys ON Product.ProdID = Keys.[KEY];
594
67
Logon information
Lab Scenario
You are the database administrator at Adventure Works. The company requires that you perform an annual audit of the database systems and their efficiency.
verify the metadata elements of the AdventureWorks
database system
Retrieve the orders data in an XML format from an external Set up a full-text catalog for product descriptions and
Lab Review
What application business requirements can be
What is the purpose of compatibility views? What statement can be used to convert relational data to
XML?
CONTAINS predicates?