Presentation is loading. Please wait.

Presentation is loading. Please wait.

12/9/2018 6:15 AM © 2004 Microsoft Corporation. All rights reserved.

Similar presentations


Presentation on theme: "12/9/2018 6:15 AM © 2004 Microsoft Corporation. All rights reserved."— Presentation transcript:

1 12/9/2018 6:15 AM © 2004 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

2 DAT327 SQL Server 2005 (Codenamed “Yukon”): Inside XQuery
Michael Rys, Arpan Desai Program Managers SQL Server XML Technologies Microsoft Corporation © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

3 Usage Of XML →Transport, Store and Query XML data Data exchange
12/9/2018 6:15 AM Usage Of XML Data exchange Business-to-business (B2B), business-to-consumer (B2C), application to application (A2A) XML is ubiquitous, extensible, platform independent transport format Content management Documents Mail Messages Data/view separation Documents, style sheets, transforms Messaging Simple Object Access Protocol (SOAP) →Transport, Store and Query XML data © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

4 XML Query Mechanisms Status quo
12/9/2018 6:15 AM XML Query Mechanisms Status quo XPath 1.0 W3C Recommendation Used in SQL Server 2000: SQLXML and OpenXML Navigation, no reshaping Limited knowledge about types XSLT Data-driven reshaping (uses XPath) MSXML, System.XML Hard to author and optimize for large amount of data No data modification language (DML) © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

5 XML Query Mechanisms XQuery
12/9/2018 6:15 AM XML Query Mechanisms XQuery Functional, declarative query language Combines XPath with node construction Operates on (XML Schema-)typed and unconstrained XML Designed to operate on large amount of data Optimizable © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

6 XQuery History Dec 1998: W3C Workshop on Querying XML
12/9/2018 6:15 AM XQuery History Dec 1998: W3C Workshop on Querying XML Sep 1999: Start of W3C XQuery WG Nov 2003: XQuery Data Model, Functions and Operators, Syntax and Semantics in Last Call Summer 2004 (expected): First Working Draft of XQuery Full-Text language proposal End of 2005 (expected): XQuery (without Full-Text, DML) in recommendation During 2006/7 (expected): Full-Text, DML in recommendation © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

7 XQuery Example declare namespace n = "http://example.com/ns1";
for $s in = >= 3] Where $s/n:heading return <topic>{data($s/n:heading)}</topic> Query Prolog Query Body © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

8 XQuery Features FLWOR: FOR / LET / WHERE / ORDER BY / RETURN FOR LET
12/9/2018 6:15 AM XQuery Features FLWOR: FOR / LET / WHERE / ORDER BY / RETURN FOR LET WHERE ORDER BY RETURN Includes XPath 2.0 = 123]) Element constructors (<topic>{…}</topic>) Order-preserving operators Input order (FLWR) Document order (XPath, union) Statically (or dynamically) typed, Strong typing with schema, weak typing without schema SQL: SELECT FROM WHERE ORDER BY & SET © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

9 XML Schema As Type System
12/9/2018 6:15 AM XML Schema As Type System XML Schema (W3C standard) Rich mechanism for type definitions and validation constraints Can be used to constrain XML documents Benefits of typed data Guarantees shape of data Allows storage and query optimizations XML type system Store XML schemas in system metadata See DAT319 for more information © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

10 12/9/2018 6:15 AM XQuery Language © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

11 XML Data Modification Insert, update, and delete XQuery extensions
XML sub-tree modification: Add or delete XML sub-trees Update values Generate consistent state © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

12 XML-DML: insert replace value of delete
12/9/2018 6:15 AM XML-DML: insert replace value of delete delete /Customer/Order[id = 42] insert <notes/> into /Customer replace value of (/Customer/name)[1] with “Nils” insert <notes/> as last into /Customer Customer insert <notes/> as first into /Customer notes notes insert <notes/> before /Customer/name name: xs:string Order notes insert <notes/> after /Customer/name “Janine” “Nils” id: xs:int Target needs to be statically one node 42 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

13 XQuery And XML-DML In SQL Server 2005
12/9/2018 6:15 AM XQuery And XML-DML In SQL Server 2005 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

14 XQuery And XML-DML In SQL Server 2005
12/9/2018 6:15 AM XQuery And XML-DML In SQL Server 2005 Beta2 is aligned on Nov XQuery Last Call working draft Added XML Data Modification Applies to single XML data type instance Methods on XML data type: query(), value(), exist(), modify(), nodes() Use SQL to iterate over collection of instances (XML-typed column) Can refer to relational data Take advantage of Schema-collection information to operate on typed XML data © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

15 12/9/2018 6:15 AM XQuery: value() Extracts an XQuery value into the SQL value and type space SELECT T.x.value( = >= ’int’) FROM T Expression has to statically be a singleton String value of atomized XQuery item is cast to SQL type SQL type has to be SQL scalar type © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

16 12/9/2018 6:15 AM XQuery: nodes() Provides OpenXML-like functionality on XML data type column in SQL Server 2005 Returns a row per selected node Each row contains a special XML data type instance that Has the context node set to the selected node Preserves the original structure and types Can only be used with the XQuery methods, count(*), IS (NOT) NULL (not modify()) © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

17 sql:column()/sql:variable()
12/9/2018 6:15 AM sql:column()/sql:variable() Map SQL value and type into XQuery values and types in context of XQuery or XML-DML sql:variable(): accesses a SQL variable int select * from T where sql:column(): accesses another column value tables: T(key int, x xml), S(key int, val int) select * from T join S on T.key=S.key where Restrictions in SQL Server “Yukon”: No XML, CLR UDT or deprecated text/ntext/image © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

18 12/9/2018 6:15 AM XQuery: modify() Used with SET: xml update T set T.xdoc.modify(‘insert <b/> into /a’) where T.id=1 Relational row-level concurrency: whole XML instance is locked © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

19 XQuery In SQL Server 2005 Subset of Standard implemented. For example:
No LET No user-defined XQuery functions Subset of XQuery built-in functions No XQuery validation (use XML datatype validation) No expression on a constructed node Dynamic errors are mapped to empty sequence No XQuery joins across different XML instances (combine instances using FOR XML) © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

20 Guidelines And Best Practices XQuery and XML-DML in SQL Server 2005
12/9/2018 6:15 AM Guidelines And Best Practices XQuery and XML-DML in SQL Server 2005 Exploit type information if available Use indices Use XQuery for property promotions Static typing provides performance benefits and early error discovery Use [1] or explicit FLWR to avoid static errors due to cardinality mismatch Use explicit casts to avoid static type errors © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

21 XQuery In .NET Framework 2005
Beta 1 is aligned on Nov XQuery Last Call working draft New common query architecture Both XSLT and XQuery compiled down to MSIL Utilizes schema information from XmlSchemaSet Supports embedding of T-SQL for easy retrieval of data from SQL Server Supports CLR extension objects to enable highly custom functionality © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

22 Supported XML Sources XML 1.0 XmlReader XPathNavigator
12/9/2018 6:15 AM Supported XML Sources XML 1.0 Files, streams, etc. XmlReader Can be implemented streaming over custom formats (ex: binary XML, ASN.1) XPathNavigator Can be implemented random access over custom structures (ex: registry, assembly metadata) sql:query() extension function Enables easy retrieval of relational data from SQL Server for processing in XQuery © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

23 XQuery in the .NET Framework 2.0
© 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

24 12/9/2018 6:15 AM sql:query() Enables utilization of T-SQL to retrieve data for processing in XQuery Can utilize FOR XML queries Also supports client side FOR XML Extremely useful for legacy stored procs T-SQL queries can be parameterized We don’t alter query string © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

25 12/9/2018 6:15 AM XQuery In System.Xml Larger portion of standard implemented. Differences in support: LET User-defined XQuery functions Dynamic errors available Joins across different XML sources allowed © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

26 More information on XML datatype Whitepapers and other information
12/9/2018 6:15 AM More information on XML datatype DAT319 Presentation Whitepapers and other information Newsgroup news:microsoft.public.sqlserver.xml W3C XQuery Our contact information Weblog: © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

27 Exclusive TechEd Offer! Receive Beta 2 of SQL Server 2005
12/9/2018 6:15 AM Next Steps: SQL Server 2005 Exclusive TechEd Offer! Receive Beta 2 of SQL Server 2005 Register for SQL Server 2005 Beta 2 at: Visit the SQL Server 2005 website: Learn more about SQL Server 2005 at TechEd Hands On Labs Rooms 6E and 6F 13 Hands On Labs Ask the Experts Track Cabanas located around CommNet Experts Available All Week © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

28 Please fill out a session evaluation on CommNet
12/9/2018 6:15 AM Please fill out a session evaluation on CommNet Q1: Overall satisfaction with the session Q2: Usefulness of the information Q3: Presenter’s knowledge of the subject Q4: Presenter’s presentation skills Q5: Effectiveness of the presentation © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

29 © 2004 Microsoft Corporation. All rights reserved.
12/9/2018 6:15 AM © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.


Download ppt "12/9/2018 6:15 AM © 2004 Microsoft Corporation. All rights reserved."

Similar presentations


Ads by Google