Download Document

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Tandem Computers wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

DBase wikipedia , lookup

Oracle Database wikipedia , lookup

Btrieve wikipedia , lookup

Relational algebra wikipedia , lookup

Team Foundation Server wikipedia , lookup

Database wikipedia , lookup

Microsoft Access wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Open Database Connectivity wikipedia , lookup

SQL wikipedia , lookup

PL/SQL wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Clusterpoint wikipedia , lookup

Database model wikipedia , lookup

Relational model wikipedia , lookup

Transcript
Inside Data Access with
SQLXML: Architecture
Guide
Adapted From
Rolandas Gricius
MCT, MCSE, MCSD
Architecture
XML
XML
XMLBulkload
BCP/SQL
Updategrams
SQL update/
insert/ delete
SQL
Server
Annotated XSD
Mapping Schemas
Query
FOR XML
Rowsets
XQuery
Query Processor
XML
SQL
Queries
XPath
FOR XML
Queries FOR XML
Queries
SQL
Queries
FOR XML
Query/Update Technologies

FOR XML (raw, auto, nested, explicit)


XML Views – XPath, XQuery


Update through XML View
Bulkload


Work with your relational database as if it was
XML file (through annotated schema)
Updategrams/Diffgrams


SQL language extension to retrieve XML
instead of rowsets
Shred large XML files into existing tables
OPENXML

Relational view over XML
Access Methods

HTTP Access via URL






SQL Query
XPath Query
Templates
ADO / OLEDB
SQLXML Managed Classes (.NET)
SOAP (Web Services)
XML Views: XDR or XSD

XML Views can be defined as:





Annotated XDR
Annotated XSD
SQL Server 2000 and SQLXML Web
Release 1 – only XDR
SQLXML 2.0 and SQLXML 3.0 – both
XDR and XSD
Future – only XSD
XML Views: XDR





Less sophisticated
Used in BizTalk
Supported in XMLDATA option
Supported in ViewMapper tool
What do your partners use?
demo
Annotated XDR
Example
XML Views: XSD





Richer
W3C Standard
What do your partners use? What do
you think they should be using?
XDR to XSD conversion tool available
New features supported in XSD only

Hide, inverse, max-depth, named
relationships, null control, nillable, fixed,
default, guid, identity
demo
Annotated XSD
Example
Recommendation

Use Annotated XSD whenever possible
Flavors of FOR XML

RAW


AUTO


Easy hierarchical XML
NESTED


XML representation of rowset
Similar to AUTO
EXPLICIT

Powerful but complex
AUTO vs. Nested




NESTED - XML transform always
executed on the client side
AUTO – XML transform always
executed on the server side
Ignores ClientSideXML property
NESTED:



Uses base table names rather than views
or aliases for element names
Aggregation and GROUP BY is supported
Multiple rowsets not supported
FOR XML or XML Views






You can use either to retrieve XML from
relational tables
Do you want to talk XML or Relational?
Do you prefer SQL or XPath?
XML Views are an abstraction layer
Think of XML Views as of SQL Views
but hierarchical rather than relational
We recommend XML Views
Use FOR XML if:




You prefer relational queries (SQL)
rather than XML queries (XPath,
XQuery)
Your XML output mimics the relational
database structure
Some complex cases not supported in
XML Views
In stored procedures
Use XML Views if:





You want to think of your database as
an XML data source
You prefer XPath to SQL
You have to generate XML according to
an existing XML schema
Your XML output is structured
differently from relational tables
XML Views are reusable for multiple
queries
EXPLICIT vs. XML Views

Which one is more powerful?



Which one is more efficient?


FOR XML EXPLICIT is
XML Views are compiled to EXPLICIT
EXPLICIT can be manually tweaked
Which one is easier?


XML Views are
Comparing XML Views to EXPLICIT is as
comparing C++ to Assembler
demo
XML Views vs.
EXPLICIT
Updategrams vs. Diffgrams



Both formats are an XML
representation of updates to the
database
Diffgrams designed as a persistence
format for DataSet
Updategrams designed as a flexible
format for small XML changes
Reasons for Updategrams





Less verbose than Diffgrams
More powerful
Fine control over concurrency
Better handling for NULLs
Strongly recommend for non-.NET
applications
Reasons for Diffgrams



Integrated with Dataset in .NET
Diffgrams are auto generated – easier
programming model
Never generate Diffgrams by hand
Bulkload vs. OPEN XML



Both technologies convert XML to
relational
Bulkload allows shredding XML into
relational tables through XML Views
OPENXML opens a relational view on
XML source
Bulkload






Middle-tier solution
Very efficient – uses BCP
Built on XML Views
Use to load large volumes of XML into
relational database
Can create relational schema for you
Very easy to use
OPENXML






Server-side solution
Might be slow – loads the entire
document in DOM
Use where you need business logic on
the server
Use in stored procedures
Use to perform relational join of XML
data with database tables
Use to pass complex arguments to
stored procedures
Access Methods




HTTP Access via URL
ADO / OLEDB
SQLXML Managed Classes (.NET)
SOAP (Web Services)
URL Query – Be Careful



Cool and easy
Run queries from Web Browser
Be careful with “sql=“ feature




Watch permissions
Allows ad-hoc queries
Recommended only for trusted
environments
Use parameter driven templates

Business logic has to be on the server
SQLXMLOLEDB




Programmatic access to SQLXML
features
SQLXML 2.0 and later
SQLXMLOLEDB is better optimized for
our scenarios than SQLOLEDB
Allows extra properties


ClientSideXML
Namespaces (for XPath)
SQLXML Managed Classes
Dataset
Fill
Update
SqlXmlAdapter
SqlXmlCommand
XPath XQuery Template
XML
XmlReader
XML
SqlCommand
FOR XML
X
M
L
V
I
E
W
Database
Managed classes



Use for .NET programming
Use to run XPath, Templates,
Updategrams
Use where you need XML Views



Rich mapping of XML to Relational
Use SqlCommand for FOR XML queries
SqlXmlCommand is an Interop layer
today
SOAP And Web Services


WSDL file describing each template
and stored proc exposed
Tool to choose which templates and
stored procedures to expose
IIS/ISAPI
WSDL
Client
SOAP
Message
SP
Message
Template
SQL
Server
Web Services



Expose Stored procedures and
templates as Web Services
Natural programming model
Very easy to access database



Dataset ds = MyStoredProcedure(param)
Use in multi-platform scenarios
Use when your connection to the
database is HTTP

Overhead of serializing all data into XML
Client vs. Server Side XML




Conversion of rowsets to XML can
happen on the Database server or midtier
Scale out
Free up the server processing cycles
Throughput considerations



BLOBS larger than 900 bytes
Short rows
Wrap existing stored procedures with
FOR XML
Architecture
XML
XML
XMLBulkload
BCP/SQL
Updategrams
SQL update/
insert/ delete
SQL
Server
Annotated XSD
Mapping Schemas
Query
FOR XML
Rowsets
XQuery
Query Processor
XML
SQL
Queries
XPath
FOR XML
Queries FOR XML
Queries
SQL
Queries
FOR XML
Additional Resources

Web page


Download SQLXML releases at:


http://msdn.microsoft.com/sqlxml/
Contact us


http://www.microsoft.com/sql/techinfo/xml/
news:microsoft.public.sqlserver.xml
Documentation



SQL Server 2000 Documentation (Books
Online)
Web Release documentation
Books
© 2002 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.