Presentation is loading. Please wait.

Presentation is loading. Please wait.

DAT 400 Inside Data Access with SQLXML: Architecture Guide Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.

Similar presentations


Presentation on theme: "DAT 400 Inside Data Access with SQLXML: Architecture Guide Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation."— Presentation transcript:

1 DAT 400 Inside Data Access with SQLXML: Architecture Guide Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation

2 SQLXML Talks SQLXML: XML Technology for SQL Server SQLXML: XML Technology for SQL Server  DAT200, Alexander Vaschillo, Jul 2 8:30 Building Web Services with SQL Server and SQLXML 3.0 Building Web Services with SQL Server and SQLXML 3.0  DAT330, Alexander Vaschillo, Jul 2 18:15 Inside data access with SQLXML: Architecture guide Inside data access with SQLXML: Architecture guide  DAT400, Alexander Vaschillo, Jul 3 10:00

3 Query/Update Technologies FOR XML (raw, auto, nested, explicit) FOR XML (raw, auto, nested, explicit)  SQL language extension to retrieve XML instead of rowsets XML Views – XPath, XQuery XML Views – XPath, XQuery  Work with your relational database as if it was XML file (through annotated schema) Updategrams/Diffgrams Updategrams/Diffgrams  Update through XML View Bulkload Bulkload  Shred large XML files into existing tables OPENXML OPENXML  Relational view over XML

4 Access Methods HTTP Access via URL HTTP Access via URL  SQL Query  XPath Query  Templates ADO / OLEDB ADO / OLEDB SQLXML Managed Classes (.NET) SQLXML Managed Classes (.NET) SOAP (Web Services) SOAP (Web Services)

5 XML Views: XDR or XSD XML Views can be defined as: XML Views can be defined as:  Annotated XDR  Annotated XSD SQL Server 2000 and SQLXML Web Release 1 – only XDR SQL Server 2000 and SQLXML Web Release 1 – only XDR SQLXML 2.0 and SQLXML 3.0 – both XDR and XSD SQLXML 2.0 and SQLXML 3.0 – both XDR and XSD Future – only XSD Future – only XSD

6 XML Views: XDR Less sophisticated Less sophisticated Used in BizTalk Used in BizTalk Supported in XMLDATA option Supported in XMLDATA option Supported in ViewMapper tool Supported in ViewMapper tool What do your partners use? What do your partners use?

7 Annotated XDR Example demo demo

8 XML Views: XSD Richer Richer W3C Standard W3C Standard What do your partners use? What do you think they should be using? What do your partners use? What do you think they should be using? XDR to XSD conversion tool available XDR to XSD conversion tool available New features supported in XSD only New features supported in XSD only  Hide, inverse, max-depth, named relationships, null control, nillable, fixed, default, guid, identity

9 Annotated XSD Example demo demo

10 Recommendation Use Annotated XSD whenever possible Use Annotated XSD whenever possible

11 Flavors of FOR XML RAW RAW  XML representation of rowset AUTO AUTO  Easy hierarchical XML NESTED NESTED  Similar to AUTO EXPLICIT EXPLICIT  Powerful but complex

12 AUTO vs. Nested NESTED - XML transform always executed on the client side NESTED - XML transform always executed on the client side AUTO – XML transform always executed on the server side AUTO – XML transform always executed on the server side Ignores ClientSideXML property Ignores ClientSideXML property NESTED: NESTED:  Uses base table names rather than views or aliases for element names  Aggregation and GROUP BY is supported  Multiple rowsets not supported

13 FOR XML or XML Views You can use either to retrieve XML from relational tables You can use either to retrieve XML from relational tables Do you want to talk XML or Relational? Do you want to talk XML or Relational? Do you prefer SQL or XPath? Do you prefer SQL or XPath? XML Views are an abstraction layer XML Views are an abstraction layer Think of XML Views as of SQL Views but hierarchical rather than relational Think of XML Views as of SQL Views but hierarchical rather than relational We recommend XML Views We recommend XML Views

14 Use FOR XML if: You prefer relational queries (SQL) rather than XML queries (XPath, XQuery) You prefer relational queries (SQL) rather than XML queries (XPath, XQuery) Your XML output mimics the relational database structure Your XML output mimics the relational database structure Some complex cases not supported in XML Views Some complex cases not supported in XML Views In stored procedures In stored procedures

15 Use XML Views if: You want to think of your database as an XML data source You want to think of your database as an XML data source You prefer XPath to SQL You prefer XPath to SQL You have to generate XML according to an existing XML schema You have to generate XML according to an existing XML schema Your XML output is structured differently from relational tables Your XML output is structured differently from relational tables XML Views are reusable for multiple queries XML Views are reusable for multiple queries

16 EXPLICIT vs. XML Views Which one is more powerful? Which one is more powerful?  FOR XML EXPLICIT is  XML Views are compiled to EXPLICIT Which one is more efficient? Which one is more efficient?  EXPLICIT can be manually tweaked Which one is easier? Which one is easier?  XML Views are  Comparing XML Views to EXPLICIT is as comparing C++ to Assembler

17 XML Views vs. EXPLICIT demo demo

18 The power of EXPLICIT demo demo  Complex hierarchies  Pivoting  Aggregation

19 Updategrams vs. Diffgrams Both formats are an XML representation of updates to the database Both formats are an XML representation of updates to the database Diffgrams designed as a persistence format for DataSet Diffgrams designed as a persistence format for DataSet Updategrams designed as a flexible format for small XML changes Updategrams designed as a flexible format for small XML changes

20 Reasons for Updategrams Less verbose than Diffgrams Less verbose than Diffgrams More powerful More powerful Fine control over concurrency Fine control over concurrency Better handling for NULLs Better handling for NULLs Strongly recommend for non-.NET applications Strongly recommend for non-.NET applications

21 Reasons for Diffgrams Integrated with Dataset in.NET Integrated with Dataset in.NET Diffgrams are auto generated – easier programming model Diffgrams are auto generated – easier programming model Never generate Diffgrams by hand Never generate Diffgrams by hand

22 The power of Updategrams demo demo  Concurrency  NULLs  Identity propagation

23 Bulkload vs. OPEN XML Both technologies convert XML to relational Both technologies convert XML to relational Bulkload allows shredding XML into relational tables through XML Views Bulkload allows shredding XML into relational tables through XML Views OPENXML opens a relational view on XML source OPENXML opens a relational view on XML source

24 Bulkload Middle-tier solution Middle-tier solution Very efficient – uses BCP Very efficient – uses BCP Built on XML Views Built on XML Views Use to load large volumes of XML into relational database Use to load large volumes of XML into relational database Can create relational schema for you Can create relational schema for you Very easy to use Very easy to use

25 OPENXML Server-side solution Server-side solution Might be slow – loads the entire document in DOM Might be slow – loads the entire document in DOM Use where you need business logic on the server Use where you need business logic on the server Use in stored procedures Use in stored procedures Use to perform relational join of XML data with database tables Use to perform relational join of XML data with database tables Use to pass complex arguments to stored procedures Use to pass complex arguments to stored procedures

26 Access Methods HTTP Access via URL HTTP Access via URL ADO / OLEDB ADO / OLEDB SQLXML Managed Classes (.NET) SQLXML Managed Classes (.NET) SOAP (Web Services) SOAP (Web Services)

27 URL Query – Be Careful Cool and easy Cool and easy Run queries from Web Browser Run queries from Web Browser Be careful with “sql=“ feature Be careful with “sql=“ feature  Watch permissions  Allows ad-hoc queries  Recommended only for trusted environments Use parameter driven templates Use parameter driven templates  Business logic has to be on the server

28 SQLXMLOLEDB Programmatic access to SQLXML features Programmatic access to SQLXML features SQLXML 2.0 and later SQLXML 2.0 and later SQLXMLOLEDB is better optimized for our scenarios than SQLOLEDB SQLXMLOLEDB is better optimized for our scenarios than SQLOLEDB Allows extra properties Allows extra properties  ClientSideXML  Namespaces (for XPath)

29 SqlXmlAdapter Dataset Fill Update SQLXML Managed Classes XmlReader Database SqlCommand FOR XML XMLVIEW SqlXmlCommand XML XPathXQueryTemplate XML

30 Managed classes Use for.NET programming Use for.NET programming Use to run XPath, Templates, Updategrams Use to run XPath, Templates, Updategrams Use where you need XML Views Use where you need XML Views  Rich mapping of XML to Relational Use SqlCommand for FOR XML queries Use SqlCommand for FOR XML queries SqlXmlCommand is an Interop layer today SqlXmlCommand is an Interop layer today

31 SOAP And Web Services WSDL file describing each template and stored proc exposed WSDL file describing each template and stored proc exposed Tool to choose which templates and stored procedures to expose Tool to choose which templates and stored procedures to expose SQLServer IIS/ISAPI Message SP Template Client SOAPMessage WSDL

32 Web Services Expose Stored procedures and templates as Web Services Expose Stored procedures and templates as Web Services Natural programming model Natural programming model Very easy to access database Very easy to access database  Dataset ds = MyStoredProcedure(param) Use in multi-platform scenarios Use in multi-platform scenarios Use when your connection to the database is HTTP Use when your connection to the database is HTTP  Overhead of serializing all data into XML

33 Client vs. Server Side XML Conversion of rowsets to XML can happen on the Database server or mid- tier Conversion of rowsets to XML can happen on the Database server or mid- tier Scale out Scale out Free up the server processing cycles Free up the server processing cycles Throughput considerations Throughput considerations  BLOBS larger than 900 bytes  Short rows Wrap existing stored procedures with FOR XML Wrap existing stored procedures with FOR XML

34 Architecture Query Processor Annotated XSD Mapping Schemas XPath XQuery Query XML SQL Server SQL Server Rowsets FOR XML SQLQueries Queries SQLQueries Queries XMLBulkload BCP/SQLXML Updategrams SQL update/ insert/ delete XML

35 Additional Resources Web page Web page  http://www.microsoft.com/sql/techinfo/xml/ Download SQLXML releases at: Download SQLXML releases at:  http://msdn.microsoft.com/sqlxml/ Contact us Contact us  PSS  news:microsoft.public.sqlserver.xml  Email us Documentation Documentation  SQL Server 2000 Documentation (Books Online)  Web Release documentation  Books

36 Resources from Microsoft Press For more information please visit the TechEd Bookshop. www.microsoft.com/mspress SQL & XML

37 Don’t forget to complete the on-line Session Feedback form on the Attendee Web site https://web.mseventseurope.com/teched/ https://web.mseventseurope.com/teched/

38 © 2002 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.


Download ppt "DAT 400 Inside Data Access with SQLXML: Architecture Guide Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation."

Similar presentations


Ads by Google