XML and SQL Server Better friends than you thought Matt Hartman.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

What is a Database By: Cristian Dubon.
An Introduction to XML Based on the W3C XML Recommendations.
Chapter 10 Database Applications Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-1 COS 346 Day 25.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
1 COS 425: Database and Information Management Systems XML and information exchange.
XML and The Relational Data Model
XML Introduction What is XML –XML is the eXtensible Markup Language –Became a W3C Recommendation in 1998 –Tag-based syntax, like HTML –You get to make.
Tutorial 11 Creating XML Document
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
1 Advanced Topics XML and Databases. 2 XML u Overview u Structure of XML Data –XML Document Type Definition DTD –Namespaces –XML Schema u Query and Transformation.
XMLII XSchema XSchema XQuery XQuery. XML Schema XML Schema is a more sophisticated schema language which addresses the drawbacks of DTDs. Supports XML.
4/20/2017.
2.2 SQL Server 2005 的 XML 支援功能. Overview XML Enhancements in SQL Server 2005 The xml Data Type Using XQuery.
XML Fundementals XML vs.. HTML XML vs.. HTML XML Document (elements vs. attributes) XML Document (elements vs. attributes) XML and RDBMS XML and RDBMS.
XML, distributed databases, and OLAP/warehousing The semantic web and a lot more.
Some Basic Database Terminology
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 1 of 31 Objectives In this lesson, you will learn to: * Generate.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
XML, CFMX CFML & SQL XML Kevin Penny, MMCP
Using XML in SQL Server 2005 NameTitleCompany. XML Overview Business Opportunity The majority of all data transmitted electronically between organizations.
Databases and LINQ Visual Basic 2010 How to Program 1.
Organizing Information Digitally Norm Friesen. Overview General properties of digital information Relational: tabular & linked Object-Oriented: inheritance.
Databases C HAPTER Chapter 10: Databases2 Databases and Structured Fields  A database is a collection of information –Typically stored as computer.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
XML in SQL Server Overview XML is a key part of any modern data environment It can be used to transmit data in a platform, application neutral form.
Ertan Deniz Instructor.  XML Schema  Document Navigation (Xpath)  Document Transformation (XSLT)
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
Another PillowTalk Presentation  2004 Dynamic Systems, Inc. Introduction to XML for SOA Lee H. Burstein,
Session II Chapter 2 – Chapter 2 – XSLhttp://
XML Overview. Chapter 8 © 2011 Pearson Education 2 Extensible Markup Language (XML) A text-based markup language (like HTML) A text-based markup language.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Sofia, Bulgaria | 9-10 October Using XQuery to Query and Manipulate XML Data Stephen Forte CTO, Corzen Inc Microsoft Regional Director NY/NJ (USA) Stephen.
Miscellaneous Excel Combining Excel and Access. – Importing, exporting and linking Parsing and manipulating data. 1.
WHAT THE HELL IS XML?. What the Hell is XML? What the hell is XML?  Markup Language  Derived from SGML (Standardized General Markup Language)  Describes.
Company LOGO OODB and XML Database Management Systems – Fall 2012 Matthew Moccaro.
 XML is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
Computer Science 101 Database Concepts. Database Collection of related data Models real world “universe” Reflects changes Specific purposes and audience.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
Utilizing XML in ColdFusion MX by Attila Domokos.
Copyrighted material John Tullis 10/17/2015 page 1 04/15/00 XML Part 3 John Tullis DePaul Instructor
XML 2nd EDITION Tutorial 1 Creating An Xml Document.
Module 18 Querying XML Data in SQL Server® 2008 R2.
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
XP 1 Creating an XML Document Developing an XML Document for the Jazz Warehouse XML Tutorial.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
+ Information Systems and Databases 2.2 Organisation.
CS 157B: Database Management Systems II February 11 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
Database Basics BCIS 3680 Enterprise Programming.
SQL Server 2005: Extending the Type System with XML.
Martin Kruliš by Martin Kruliš (v1.1)1.
XML. HTML Before you continue you should have a basic understanding of the following: HTML HTML was designed to display data and to focus on how data.
Module 3: Using XML. Overview Retrieving XML by Using FOR XML Shredding XML by Using OPENXML Introducing XQuery Using the xml Data Type.
Dave Salinas. What is XML? XML stands for eXtensible Markup Language Markup language, like HTML HTML was designed to display data, whereas XML was designed.
SEMI-STRUCTURED DATA (XML) 1. SEMI-STRUCTURED DATA ER, Relational, ODL data models are all based on schema Structure of data is rigid and known is advance.
XML Extensible Markup Language
PART 1 XML Basics. Slide 2 Why XML Here? You need to understand the basics of XML to do much with Android All of they layout and configuration files are.
Connecting to External Data. Financial data can be obtained from a number of different data sources.
XML Databases Presented By: Pardeep MT15042 Anurag Goel MT15006.
XML: Extensible Markup Language
Dirt, Spit, and Happy FLWOR
XML in Web Technologies
Microsoft Access 2003 Illustrated Complete
XML and Databases.
XML Data Introduction, Well-formed XML.
Database Applications
XML? What’s this doing in my database? Adam Koehler
Presentation transcript:

XML and SQL Server Better friends than you thought Matt Hartman

I’m a DBA not a developer. Why should I give two hoots about XML anyway? 1.XML is widely used for data transfers 2.XML is the Microsoft standard format for Configuration 3.XML data isn’t always worth parsing and storing in relational format 4.Sometimes someone hands you a giant dump of XML and you are told to “deal with it.” 2

What this Presentation Covers 1.What is XML and all these other “some other letter(s)”-ML’s? 2.XML in SQL Server: FOR XML, XPath, XQuery and the XML data type 3.A real world example 4.Additional tools that might help with those giant XML dumps 3

Built in SQL Server XML Toolset 1.XML Data Type 2.XQuery 3.XPath 4.FOR XML 4

What is XML? ML means “Mark-up Language” Normal text is like this. There is nothing that tells the computer what to do. So all you get back is the text without formatting. Mark Up Languages have Tags Marked up language has tags, or a notification to the computer that it should do something with the text. In a mark up language such as HTML, a tag might tell a computer to put some text in bold. Or maybe you want something more complex than that. Either way, the open tag: and closing tag: tell the computer, based on the mark up language rules, what it should do with the text in between the tags. Or in the case of Twitter and a #hashtag, what the computer should do with the single word following the #. In this case it means to make your important snippet of thought searchable under the specific #WordsWithoutSpaces that you broadcast to the entire world. 5

What is XML? X means “eXtensible”  X because the World Wide Web Consortium doesn’t realize that the word “extensible” starts with an “e.”  Extensible means you can “extend it” to define your own unique data, as long as you follow some basic rules. 6

What is XML? XML is a mark-up language approach to defining any given hierarchical dataset. Heirarchical data: A building has one or more rooms. Each room has one or more closets. Each closet has one or more articles of clothing. Each room has one or more articles of furniture. But an article of clothing never “has a building,” nor does a closet have a room. 7

XML Format XML can define anything, as long as it is consistent and follows standard rules: Favorite Shoes Old Shoes New Shoes Cute Shoes Ugly Shoes 8

XML Format 1.The data must be hierarchical and ordered. 2.All elements must have a closing tag, or a single combined open and close tag. 3.You must close nested elements before you close their parent. 4.Attributes are assigned to elements on a one to one basis. 5.Sorry DBA’s and SQL developers, but XML is case sensitive. 9

XML Namespaces and XSLT 1.Namespaces: Landon Donovan Michael Bradley 2.XSLT 10

SQL Server and XML 1.Store XML data in SQL with the XML data type. 2.Query XML data types directly with XQuery using XPath references. 3.Shred XML data and import it into relational tables, rows and columns using OPENXML. 4.Output relational data to XML format using FOR XML.

XML Data Type 1.Stores valid XML 2.2GB Maximum Size 3.You can query it to extract a derived XML value using XQuery 4.Great for storing data in transit 12

XQuery and XPath 1.XQuery 1.Available using Query method of an XML Data Type 2.Language with it’s own syntax and rules 2.XPath 1.Standard expressions to navigate XML 2.XQuery uses XPath references

XPath /root /playerany element (by name) /player/node test /player/..axis (parent) /player/name/text()method

XQuery: FLWOR F: Forfor $p in players/player L: Letlet $g := $p/careergoals W: Wherewhere $g > 0 O: Order Byorder by ($g)[1] R: Return {$g/text()} 15

Relational Data to XML Output FOR XML Clause FOR XML Raw“row” elements w/ attributes FOR XML Autospecify columns as attributes or elements More Useful: FOR XML Pathspecify exact XML to return 16

OPENXML 1.Use OPENXML to import XML data into SELECT * FROM OPENXML 'players/player', 2) WITH (name varchar(10), careergoals int); 1.Foreign Keys can be difficult if not defined in XML 17

Real World Example 1.Import Dona Ana County property records (1.5 GB file) into SQL Server 2.Generate database schema based on XSLT of the properties XML 3.Few primary key candidates defined in the XML data 4.No foreign key relationships defined 18

Additional Import Approaches 1..NET Code import-data-from-xml-to-sql-part-1.aspx 1.Exult XML Conversion Wizard

Thank you to our Sponsors

Thank you! Register at and join LCEP (southwest) Free stuff and Q&A We send updates, so check your Come back next month! Next month’s meeting at City Hall in Las Cruces. Details forthcoming…