SlideShare a Scribd company logo
1 of 34
XML in My Database!
Implementation on a Live e-Store
Using SQL Server 2005
Denise McInerney
Silicon Valley SQL Server User Group
August 19, 2008
August 19, 2008 Denise McInerney 2
Agenda
 Introduction
 XML Native Data Type Overview
 Project Definition
 Decision to Use XML Data Type
 Design Choices
 Getting Data In and Out
 Impact on Performance & Maintenance
 Q & A
August 19, 2008 Denise McInerney 3
Introduction
 10 years SQL Server DBA
 Currently Staff Development DBA
at Intuit
 Web-based OLTP applications
 Design
 Performance Tuning
 MCDBA/MCTS
 PASS volunteer
 Women in Technology SIG Chairperson
August 19, 2008 Denise McInerney 4
PASS Community Summit 2008
 November 18-21, 2008
Washington State Convention & Trade Center,
Seattle
 Over 100 sessions, 4 Tracks
 DBA, App Dev, BI, Professional Development
 MVPs, Microsoft Development Team
 Itzik Ben-Gan, Kalen Delaney, Kimberley Tripp,
Greg Low, Brian Knight, Brad McGehee, Joe Webb,
Kevin Kline
 Many Networking Opportunities
 Vendor Expo
 http://summit2008.sqlpass.org/
August 19, 2008 Denise McInerney 5
Agenda
 Introduction
 XML Native Data Type Overview
 Project Definition
 Decision to Use XML Data Type
 Design Choices
 Getting Data In and Out
 Impact on Performance & Maintenance
 Q & A
August 19, 2008 Denise McInerney 6
XML Data Type Overview
 Introduced in SQL Server 2005
 Allows storage of XML documents in database
 Before SS 2005
 Store in text columns
 Shredded into relational structures
 Produced using FOR XML
 Define a column or variable as XML
CREATE TABLE T1
(Col1 int, Col2 xml)
 Will behave like other data types, mostly
 Can query with XML data type methods
 Can be validated against an XML schema
August 19, 2008 Denise McInerney 7
XML Data Type Overview
 XML data type not a replacement for
relational structure
 Appropriate for
 semi- or unstructured data
 containment hierarchy, instead of
references among entities
 Large object storage (documents)
 Platform independence, data portability
 See Books Online for more
August 19, 2008 Denise McInerney 8
Agenda
 Introduction
 XML Native Data Type Overview
 Project Definition
 Reason for Using XML
 Design Choices
 Getting Data In and Out
 Impact on Performance & Maintenance
 Q & A
August 19, 2008 Denise McInerney 9
Project Definition
 Existing e-commerce system
 ~4 million orders
 Front-end application being completely
rewritten
 Opportunity to change the data model
August 19, 2008 Denise McInerney 10
Project Definition
 What is the data?
 Custom printed products
 Contents—what is printed
 Name, address, etc.
 Descriptors—how it’s printed
 Location on item, font face, color, size
 Every product different
 New products introduced regularly
August 19, 2008 Denise McInerney 11
Project Definition
 Stored in HUGE relational tables
 Nested 5 deep
 3 sets
 1 million – 30 million rows
 Ongoing maintenance & performance
problems
 Existing design did not scale
 Data shared with two external systems
August 19, 2008 Denise McInerney 12
Project Definition
August 19, 2008 Denise McInerney 13
August 19, 2008 Denise McInerney 14
Agenda
 Introduction
 XML Native Data Type Overview
 Project Definition
 Decision to Use XML Data Type
 Design Choices
 Getting Data In and Out
 Impact on Performance & Maintenance
 Q & A
August 19, 2008 Denise McInerney 15
Decision to Use XML Data Type
 Data seemed like it “wanted” to be in
XML
 Data met criteria in Microsoft
recommendation
 Hierarchical
 Structure changes
 Needed to be portable
 New application design based on using
XML documents
August 19, 2008 Denise McInerney 16
Decision to Use XML Data Type
 Convince the rest of the team
 Present how it could work
 Yes, it can be queried
 No, it will not eat up terabytes
 Proof-of-concept
 Sample XML document in column
 Prove the application can use it
August 19, 2008 Denise McInerney 17
Agenda
 Introduction
 XML Native Data Type Overview
 Project Definition
 Decision to Use XML Data Type
 Design Choices
 Getting Data In and Out
 Impact on Performance & Maintenance
 Q & A
August 19, 2008 Denise McInerney 18
Design Choices
 Define what is in & what is out
 Very important choices
 XML schema definition determined by needs
of application
 Everything else up for discussion
 Know your WHEREs
 99% of queries based on ID
 ID gets its own column
 Create & update dates also
 Everything else in XML doc/column
August 19, 2008 Denise McInerney 19
Design Choices
 Redundant data?
 In XML column and relational table
 Determined to be necessary in one case
 Be careful here!
 To Bind or Not to Bind?
 Decided “no”
 Many XML schemas, more to come
 Application doing validation
August 19, 2008 Denise McInerney 20
Design Choices
 Final table had 4 columns
 Three tables, one design
 One for work-in-progress
 One for customer-initiated save
 One for final product
 “Final” insert validated against XSD
August 19, 2008 Denise McInerney 21
Design Choices
 Index on XML?
 Can improve performance, can be costly
 Decided not necessary
 All queries first based on PK
 Return small number of rows
 Less XML to be shredded
August 19, 2008 Denise McInerney 22
Agenda
 Introduction
 XML Native Data Type Overview
 Project Definition
 Decision to Use XML Data Type
 Design Choices
 Getting Data In and Out
 Impact on Performance & Maintenance
 Q & A
August 19, 2008 Denise McInerney 23
Getting Data In
 For new records, simple insert
 Entire XML doc in column
 Existing 4 million records, not so simple
 Data had to be preserved, available to
customers right away
 Some bad data existed
 Data conversion biggest challenge
August 19, 2008 Denise McInerney 24
Getting Data In
 Started with FOR XML query
 Tried to create XML doc as defined by
XSD
 Table design made FOR XML difficult
 FOR XML
 Column name = element or attribute name
 Data = element or attribute value
 In relational tables, 1 column contained
name, 1 column contained value
 Painstaking process, slow performance
August 19, 2008 Denise McInerney 25
Getting Data In
 Realized SQL alone was not right tool
 Better answer through collaboration
 Used FOR XML to get relational to XML
 Used code to transform 1st XML to final
XML document
August 19, 2008 Denise McInerney 26
August 19, 2008 Denise McInerney 27
Getting Data In
 Lots of trial and error
 Broke it into pieces
 Bad data
 Many different use cases
 Phased approach
 Did bulk of conversion before launch
 Night of launch ~10,000 records to convert
 Prepared for problems
 Preserved data at every stage of conversion
 Needed it when bugs arose
 Collaboration with developer & production
DBA crucial to success
August 19, 2008 Denise McInerney 28
Getting Data Out
 Most very simple SELECT
SELECT xml_col
WHERE id_col = myID
 Some use of VALUE method
 Retrieves value of element or attribute
 Great performance
 Fixing bugs
 MODIFY method
August 19, 2008 Denise McInerney 29
August 19, 2008 Denise McInerney 30
Agenda
 Introduction
 XML Native Data Type Overview
 Project Definition
 Decision to Use XML Data Type
 Design Choices
 Getting Data In and Out
 Impact on Performance &
Maintenance
 Q & A
August 19, 2008 Denise McInerney 31
Impact on Performance &
Maintenance
 In production 9 months
 Query performance much better
 No timeouts
 Index maintenance problems
eliminated
 Database shrunk
August 19, 2008 Denise McInerney 32
Impact on Performance &
Maintenance
 BEFORE
 Relational Tables + Indexes
 77.5 Gigabytes
 AFTER
 Table with XML column + PK index
 20 Gigabytes
 74% reduction in used space
August 19, 2008 Denise McInerney 33
Agenda
 Introduction
 XML Native Data Type Overview
 Project Definition
 Reason for Using XML
 Design Choices
 Getting Data In and Out
 Impact on Performance & Maintenance
 Q & A
August 19, 2008 Denise McInerney 34
Additional Resources
 Books OnLine
 http://msdn.microsoft.com/xml/default.aspx?
pull=/library/en-
us/dnsql90/html/sql2k5xml.asp
 http://msdn.microsoft.com/xml/default.aspx?
pull=/library/en-
us/dnsql90/html/sql2k5xmloptions.asp
 http://msdn.microsoft.com/xml/default.aspx?
pull=/library/en-
us/dnsql90/html/sql25xmlbp.asp
 MS Newsgroups, SQLJunkies.com,
SQLTeam.com…and every SQL Server site
 Contact me: denise.mcinerney@sqlpass.org

More Related Content

Viewers also liked

Lca seminar modified
Lca seminar modifiedLca seminar modified
Lca seminar modifiedInbok Lee
 
Gesture-aware remote controls: guidelines and interaction techniques
Gesture-aware remote controls: guidelines and interaction techniquesGesture-aware remote controls: guidelines and interaction techniques
Gesture-aware remote controls: guidelines and interaction techniquesDong-Bach Vo
 
[DL Hacks輪読] Semi-Supervised Learning with Ladder Networks (NIPS2015)
[DL Hacks輪読] Semi-Supervised Learning with Ladder Networks (NIPS2015)[DL Hacks輪読] Semi-Supervised Learning with Ladder Networks (NIPS2015)
[DL Hacks輪読] Semi-Supervised Learning with Ladder Networks (NIPS2015)Yusuke Iwasawa
 
Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...go_oh
 
The system development life cycle (SDLC)
The system development life cycle (SDLC)The system development life cycle (SDLC)
The system development life cycle (SDLC)gourav kottawar
 
Masterizing php data structure 102
Masterizing php data structure 102Masterizing php data structure 102
Masterizing php data structure 102Patrick Allaert
 
Building and deploying PHP applications with Phing
Building and deploying PHP applications with PhingBuilding and deploying PHP applications with Phing
Building and deploying PHP applications with PhingMichiel Rook
 
Semi supervised learning
Semi supervised learningSemi supervised learning
Semi supervised learningAhmed Taha
 
Extending Word2Vec for Performance and Semi-Supervised Learning-(Michael Mala...
Extending Word2Vec for Performance and Semi-Supervised Learning-(Michael Mala...Extending Word2Vec for Performance and Semi-Supervised Learning-(Michael Mala...
Extending Word2Vec for Performance and Semi-Supervised Learning-(Michael Mala...Spark Summit
 
PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)Nikita Popov
 
Biomolecular interaction analysis (BIA) techniques
Biomolecular interaction analysis (BIA) techniquesBiomolecular interaction analysis (BIA) techniques
Biomolecular interaction analysis (BIA) techniquesN Poorin
 
HTTP cookie hijacking in the wild: security and privacy implications
HTTP cookie hijacking in the wild: security and privacy implicationsHTTP cookie hijacking in the wild: security and privacy implications
HTTP cookie hijacking in the wild: security and privacy implicationsPriyanka Aash
 
LCA and RMQ ~簡潔もあるよ!~
LCA and RMQ ~簡潔もあるよ!~LCA and RMQ ~簡潔もあるよ!~
LCA and RMQ ~簡潔もあるよ!~Yuma Inoue
 
Cookies and browser exploits
Cookies and browser exploitsCookies and browser exploits
Cookies and browser exploitsIftach Ian Amit
 
Semi-Supervised Learning
Semi-Supervised LearningSemi-Supervised Learning
Semi-Supervised LearningLukas Tencer
 
What is Agile Software Development?
What is Agile Software Development?What is Agile Software Development?
What is Agile Software Development?Blossom IO Inc.
 

Viewers also liked (18)

Lca seminar modified
Lca seminar modifiedLca seminar modified
Lca seminar modified
 
Gesture-aware remote controls: guidelines and interaction techniques
Gesture-aware remote controls: guidelines and interaction techniquesGesture-aware remote controls: guidelines and interaction techniques
Gesture-aware remote controls: guidelines and interaction techniques
 
Algorithms and Data Structures~hmftj
Algorithms and Data Structures~hmftjAlgorithms and Data Structures~hmftj
Algorithms and Data Structures~hmftj
 
[DL Hacks輪読] Semi-Supervised Learning with Ladder Networks (NIPS2015)
[DL Hacks輪読] Semi-Supervised Learning with Ladder Networks (NIPS2015)[DL Hacks輪読] Semi-Supervised Learning with Ladder Networks (NIPS2015)
[DL Hacks輪読] Semi-Supervised Learning with Ladder Networks (NIPS2015)
 
Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...
 
The system development life cycle (SDLC)
The system development life cycle (SDLC)The system development life cycle (SDLC)
The system development life cycle (SDLC)
 
Masterizing php data structure 102
Masterizing php data structure 102Masterizing php data structure 102
Masterizing php data structure 102
 
Building and deploying PHP applications with Phing
Building and deploying PHP applications with PhingBuilding and deploying PHP applications with Phing
Building and deploying PHP applications with Phing
 
Semi supervised learning
Semi supervised learningSemi supervised learning
Semi supervised learning
 
Extending Word2Vec for Performance and Semi-Supervised Learning-(Michael Mala...
Extending Word2Vec for Performance and Semi-Supervised Learning-(Michael Mala...Extending Word2Vec for Performance and Semi-Supervised Learning-(Michael Mala...
Extending Word2Vec for Performance and Semi-Supervised Learning-(Michael Mala...
 
System Development Life Cycle (SDLC) - Part II
System Development Life Cycle (SDLC) - Part IISystem Development Life Cycle (SDLC) - Part II
System Development Life Cycle (SDLC) - Part II
 
PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)
 
Biomolecular interaction analysis (BIA) techniques
Biomolecular interaction analysis (BIA) techniquesBiomolecular interaction analysis (BIA) techniques
Biomolecular interaction analysis (BIA) techniques
 
HTTP cookie hijacking in the wild: security and privacy implications
HTTP cookie hijacking in the wild: security and privacy implicationsHTTP cookie hijacking in the wild: security and privacy implications
HTTP cookie hijacking in the wild: security and privacy implications
 
LCA and RMQ ~簡潔もあるよ!~
LCA and RMQ ~簡潔もあるよ!~LCA and RMQ ~簡潔もあるよ!~
LCA and RMQ ~簡潔もあるよ!~
 
Cookies and browser exploits
Cookies and browser exploitsCookies and browser exploits
Cookies and browser exploits
 
Semi-Supervised Learning
Semi-Supervised LearningSemi-Supervised Learning
Semi-Supervised Learning
 
What is Agile Software Development?
What is Agile Software Development?What is Agile Software Development?
What is Agile Software Development?
 

Similar to XML In My Database!

Smart Data for Smart Labs
Smart Data for Smart Labs Smart Data for Smart Labs
Smart Data for Smart Labs OSTHUS
 
Architecting Cloudy Applications
Architecting Cloudy ApplicationsArchitecting Cloudy Applications
Architecting Cloudy ApplicationsDavid Chou
 
Data Mining With Excel 2007 And SQL Server 2008
Data Mining With Excel 2007 And SQL Server 2008Data Mining With Excel 2007 And SQL Server 2008
Data Mining With Excel 2007 And SQL Server 2008Mark Tabladillo
 
Big Data in Engineering Applications
Big Data in Engineering ApplicationsBig Data in Engineering Applications
Big Data in Engineering Applicationsamit kumar
 
Qo Introduction V2
Qo Introduction V2Qo Introduction V2
Qo Introduction V2Joe_F
 
No sql mongodb_publicsector2014_pp
No sql mongodb_publicsector2014_ppNo sql mongodb_publicsector2014_pp
No sql mongodb_publicsector2014_ppMongoDB
 
Bigtable a distributed storage system
Bigtable a distributed storage systemBigtable a distributed storage system
Bigtable a distributed storage systemDevyani Vaidya
 
Bigtable a distributed storage system
Bigtable a distributed storage systemBigtable a distributed storage system
Bigtable a distributed storage systemDevyani Vaidya
 
Secrets of Enterprise Data Mining 201310
Secrets of Enterprise Data Mining 201310Secrets of Enterprise Data Mining 201310
Secrets of Enterprise Data Mining 201310Mark Tabladillo
 
Data Science as a Service: Intersection of Cloud Computing and Data Science
Data Science as a Service: Intersection of Cloud Computing and Data ScienceData Science as a Service: Intersection of Cloud Computing and Data Science
Data Science as a Service: Intersection of Cloud Computing and Data SciencePouria Amirian
 
Data Science as a Service: Intersection of Cloud Computing and Data Science
Data Science as a Service: Intersection of Cloud Computing and Data ScienceData Science as a Service: Intersection of Cloud Computing and Data Science
Data Science as a Service: Intersection of Cloud Computing and Data SciencePouria Amirian
 
Secrets of Enterprise Data Mining 201305
Secrets of Enterprise Data Mining 201305Secrets of Enterprise Data Mining 201305
Secrets of Enterprise Data Mining 201305Mark Tabladillo
 
Generating XML schemas from a Logical Data Model (EDW 2011)
Generating XML schemas from a Logical Data Model (EDW 2011)Generating XML schemas from a Logical Data Model (EDW 2011)
Generating XML schemas from a Logical Data Model (EDW 2011)George McGeachie
 
Extreme Productivity in the Enterprise The User is the Developer is the User
Extreme Productivity in the Enterprise The User is the Developer is the UserExtreme Productivity in the Enterprise The User is the Developer is the User
Extreme Productivity in the Enterprise The User is the Developer is the Usercoolstuff
 
DAMA Webinar: Turn Grand Designs into a Reality with Data Virtualization
DAMA Webinar: Turn Grand Designs into a Reality with Data VirtualizationDAMA Webinar: Turn Grand Designs into a Reality with Data Virtualization
DAMA Webinar: Turn Grand Designs into a Reality with Data VirtualizationDenodo
 
The New Role of Data in the Changing Energy & Utilities Landscape
The New Role of Data in the Changing Energy & Utilities LandscapeThe New Role of Data in the Changing Energy & Utilities Landscape
The New Role of Data in the Changing Energy & Utilities LandscapeDenodo
 
DATA @ NFLX (Tableau Conference 2014 Presentation)
DATA @ NFLX (Tableau Conference 2014 Presentation)DATA @ NFLX (Tableau Conference 2014 Presentation)
DATA @ NFLX (Tableau Conference 2014 Presentation)Blake Irvine
 
Data Modeling Fundamentals
Data Modeling FundamentalsData Modeling Fundamentals
Data Modeling FundamentalsDATAVERSITY
 
2017 Networking & Scale-out Storage Brand Leader Mini-Report
2017 Networking & Scale-out Storage Brand Leader Mini-Report2017 Networking & Scale-out Storage Brand Leader Mini-Report
2017 Networking & Scale-out Storage Brand Leader Mini-ReportIT Brand Pulse
 

Similar to XML In My Database! (20)

16 bealer
16 bealer16 bealer
16 bealer
 
Smart Data for Smart Labs
Smart Data for Smart Labs Smart Data for Smart Labs
Smart Data for Smart Labs
 
Architecting Cloudy Applications
Architecting Cloudy ApplicationsArchitecting Cloudy Applications
Architecting Cloudy Applications
 
Data Mining With Excel 2007 And SQL Server 2008
Data Mining With Excel 2007 And SQL Server 2008Data Mining With Excel 2007 And SQL Server 2008
Data Mining With Excel 2007 And SQL Server 2008
 
Big Data in Engineering Applications
Big Data in Engineering ApplicationsBig Data in Engineering Applications
Big Data in Engineering Applications
 
Qo Introduction V2
Qo Introduction V2Qo Introduction V2
Qo Introduction V2
 
No sql mongodb_publicsector2014_pp
No sql mongodb_publicsector2014_ppNo sql mongodb_publicsector2014_pp
No sql mongodb_publicsector2014_pp
 
Bigtable a distributed storage system
Bigtable a distributed storage systemBigtable a distributed storage system
Bigtable a distributed storage system
 
Bigtable a distributed storage system
Bigtable a distributed storage systemBigtable a distributed storage system
Bigtable a distributed storage system
 
Secrets of Enterprise Data Mining 201310
Secrets of Enterprise Data Mining 201310Secrets of Enterprise Data Mining 201310
Secrets of Enterprise Data Mining 201310
 
Data Science as a Service: Intersection of Cloud Computing and Data Science
Data Science as a Service: Intersection of Cloud Computing and Data ScienceData Science as a Service: Intersection of Cloud Computing and Data Science
Data Science as a Service: Intersection of Cloud Computing and Data Science
 
Data Science as a Service: Intersection of Cloud Computing and Data Science
Data Science as a Service: Intersection of Cloud Computing and Data ScienceData Science as a Service: Intersection of Cloud Computing and Data Science
Data Science as a Service: Intersection of Cloud Computing and Data Science
 
Secrets of Enterprise Data Mining 201305
Secrets of Enterprise Data Mining 201305Secrets of Enterprise Data Mining 201305
Secrets of Enterprise Data Mining 201305
 
Generating XML schemas from a Logical Data Model (EDW 2011)
Generating XML schemas from a Logical Data Model (EDW 2011)Generating XML schemas from a Logical Data Model (EDW 2011)
Generating XML schemas from a Logical Data Model (EDW 2011)
 
Extreme Productivity in the Enterprise The User is the Developer is the User
Extreme Productivity in the Enterprise The User is the Developer is the UserExtreme Productivity in the Enterprise The User is the Developer is the User
Extreme Productivity in the Enterprise The User is the Developer is the User
 
DAMA Webinar: Turn Grand Designs into a Reality with Data Virtualization
DAMA Webinar: Turn Grand Designs into a Reality with Data VirtualizationDAMA Webinar: Turn Grand Designs into a Reality with Data Virtualization
DAMA Webinar: Turn Grand Designs into a Reality with Data Virtualization
 
The New Role of Data in the Changing Energy & Utilities Landscape
The New Role of Data in the Changing Energy & Utilities LandscapeThe New Role of Data in the Changing Energy & Utilities Landscape
The New Role of Data in the Changing Energy & Utilities Landscape
 
DATA @ NFLX (Tableau Conference 2014 Presentation)
DATA @ NFLX (Tableau Conference 2014 Presentation)DATA @ NFLX (Tableau Conference 2014 Presentation)
DATA @ NFLX (Tableau Conference 2014 Presentation)
 
Data Modeling Fundamentals
Data Modeling FundamentalsData Modeling Fundamentals
Data Modeling Fundamentals
 
2017 Networking & Scale-out Storage Brand Leader Mini-Report
2017 Networking & Scale-out Storage Brand Leader Mini-Report2017 Networking & Scale-out Storage Brand Leader Mini-Report
2017 Networking & Scale-out Storage Brand Leader Mini-Report
 

Recently uploaded

Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceDelhi Call girls
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...shambhavirathore45
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxolyaivanovalion
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...amitlee9823
 

Recently uploaded (20)

Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptx
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 

XML In My Database!

  • 1. XML in My Database! Implementation on a Live e-Store Using SQL Server 2005 Denise McInerney Silicon Valley SQL Server User Group August 19, 2008
  • 2. August 19, 2008 Denise McInerney 2 Agenda  Introduction  XML Native Data Type Overview  Project Definition  Decision to Use XML Data Type  Design Choices  Getting Data In and Out  Impact on Performance & Maintenance  Q & A
  • 3. August 19, 2008 Denise McInerney 3 Introduction  10 years SQL Server DBA  Currently Staff Development DBA at Intuit  Web-based OLTP applications  Design  Performance Tuning  MCDBA/MCTS  PASS volunteer  Women in Technology SIG Chairperson
  • 4. August 19, 2008 Denise McInerney 4 PASS Community Summit 2008  November 18-21, 2008 Washington State Convention & Trade Center, Seattle  Over 100 sessions, 4 Tracks  DBA, App Dev, BI, Professional Development  MVPs, Microsoft Development Team  Itzik Ben-Gan, Kalen Delaney, Kimberley Tripp, Greg Low, Brian Knight, Brad McGehee, Joe Webb, Kevin Kline  Many Networking Opportunities  Vendor Expo  http://summit2008.sqlpass.org/
  • 5. August 19, 2008 Denise McInerney 5 Agenda  Introduction  XML Native Data Type Overview  Project Definition  Decision to Use XML Data Type  Design Choices  Getting Data In and Out  Impact on Performance & Maintenance  Q & A
  • 6. August 19, 2008 Denise McInerney 6 XML Data Type Overview  Introduced in SQL Server 2005  Allows storage of XML documents in database  Before SS 2005  Store in text columns  Shredded into relational structures  Produced using FOR XML  Define a column or variable as XML CREATE TABLE T1 (Col1 int, Col2 xml)  Will behave like other data types, mostly  Can query with XML data type methods  Can be validated against an XML schema
  • 7. August 19, 2008 Denise McInerney 7 XML Data Type Overview  XML data type not a replacement for relational structure  Appropriate for  semi- or unstructured data  containment hierarchy, instead of references among entities  Large object storage (documents)  Platform independence, data portability  See Books Online for more
  • 8. August 19, 2008 Denise McInerney 8 Agenda  Introduction  XML Native Data Type Overview  Project Definition  Reason for Using XML  Design Choices  Getting Data In and Out  Impact on Performance & Maintenance  Q & A
  • 9. August 19, 2008 Denise McInerney 9 Project Definition  Existing e-commerce system  ~4 million orders  Front-end application being completely rewritten  Opportunity to change the data model
  • 10. August 19, 2008 Denise McInerney 10 Project Definition  What is the data?  Custom printed products  Contents—what is printed  Name, address, etc.  Descriptors—how it’s printed  Location on item, font face, color, size  Every product different  New products introduced regularly
  • 11. August 19, 2008 Denise McInerney 11 Project Definition  Stored in HUGE relational tables  Nested 5 deep  3 sets  1 million – 30 million rows  Ongoing maintenance & performance problems  Existing design did not scale  Data shared with two external systems
  • 12. August 19, 2008 Denise McInerney 12 Project Definition
  • 13. August 19, 2008 Denise McInerney 13
  • 14. August 19, 2008 Denise McInerney 14 Agenda  Introduction  XML Native Data Type Overview  Project Definition  Decision to Use XML Data Type  Design Choices  Getting Data In and Out  Impact on Performance & Maintenance  Q & A
  • 15. August 19, 2008 Denise McInerney 15 Decision to Use XML Data Type  Data seemed like it “wanted” to be in XML  Data met criteria in Microsoft recommendation  Hierarchical  Structure changes  Needed to be portable  New application design based on using XML documents
  • 16. August 19, 2008 Denise McInerney 16 Decision to Use XML Data Type  Convince the rest of the team  Present how it could work  Yes, it can be queried  No, it will not eat up terabytes  Proof-of-concept  Sample XML document in column  Prove the application can use it
  • 17. August 19, 2008 Denise McInerney 17 Agenda  Introduction  XML Native Data Type Overview  Project Definition  Decision to Use XML Data Type  Design Choices  Getting Data In and Out  Impact on Performance & Maintenance  Q & A
  • 18. August 19, 2008 Denise McInerney 18 Design Choices  Define what is in & what is out  Very important choices  XML schema definition determined by needs of application  Everything else up for discussion  Know your WHEREs  99% of queries based on ID  ID gets its own column  Create & update dates also  Everything else in XML doc/column
  • 19. August 19, 2008 Denise McInerney 19 Design Choices  Redundant data?  In XML column and relational table  Determined to be necessary in one case  Be careful here!  To Bind or Not to Bind?  Decided “no”  Many XML schemas, more to come  Application doing validation
  • 20. August 19, 2008 Denise McInerney 20 Design Choices  Final table had 4 columns  Three tables, one design  One for work-in-progress  One for customer-initiated save  One for final product  “Final” insert validated against XSD
  • 21. August 19, 2008 Denise McInerney 21 Design Choices  Index on XML?  Can improve performance, can be costly  Decided not necessary  All queries first based on PK  Return small number of rows  Less XML to be shredded
  • 22. August 19, 2008 Denise McInerney 22 Agenda  Introduction  XML Native Data Type Overview  Project Definition  Decision to Use XML Data Type  Design Choices  Getting Data In and Out  Impact on Performance & Maintenance  Q & A
  • 23. August 19, 2008 Denise McInerney 23 Getting Data In  For new records, simple insert  Entire XML doc in column  Existing 4 million records, not so simple  Data had to be preserved, available to customers right away  Some bad data existed  Data conversion biggest challenge
  • 24. August 19, 2008 Denise McInerney 24 Getting Data In  Started with FOR XML query  Tried to create XML doc as defined by XSD  Table design made FOR XML difficult  FOR XML  Column name = element or attribute name  Data = element or attribute value  In relational tables, 1 column contained name, 1 column contained value  Painstaking process, slow performance
  • 25. August 19, 2008 Denise McInerney 25 Getting Data In  Realized SQL alone was not right tool  Better answer through collaboration  Used FOR XML to get relational to XML  Used code to transform 1st XML to final XML document
  • 26. August 19, 2008 Denise McInerney 26
  • 27. August 19, 2008 Denise McInerney 27 Getting Data In  Lots of trial and error  Broke it into pieces  Bad data  Many different use cases  Phased approach  Did bulk of conversion before launch  Night of launch ~10,000 records to convert  Prepared for problems  Preserved data at every stage of conversion  Needed it when bugs arose  Collaboration with developer & production DBA crucial to success
  • 28. August 19, 2008 Denise McInerney 28 Getting Data Out  Most very simple SELECT SELECT xml_col WHERE id_col = myID  Some use of VALUE method  Retrieves value of element or attribute  Great performance  Fixing bugs  MODIFY method
  • 29. August 19, 2008 Denise McInerney 29
  • 30. August 19, 2008 Denise McInerney 30 Agenda  Introduction  XML Native Data Type Overview  Project Definition  Decision to Use XML Data Type  Design Choices  Getting Data In and Out  Impact on Performance & Maintenance  Q & A
  • 31. August 19, 2008 Denise McInerney 31 Impact on Performance & Maintenance  In production 9 months  Query performance much better  No timeouts  Index maintenance problems eliminated  Database shrunk
  • 32. August 19, 2008 Denise McInerney 32 Impact on Performance & Maintenance  BEFORE  Relational Tables + Indexes  77.5 Gigabytes  AFTER  Table with XML column + PK index  20 Gigabytes  74% reduction in used space
  • 33. August 19, 2008 Denise McInerney 33 Agenda  Introduction  XML Native Data Type Overview  Project Definition  Reason for Using XML  Design Choices  Getting Data In and Out  Impact on Performance & Maintenance  Q & A
  • 34. August 19, 2008 Denise McInerney 34 Additional Resources  Books OnLine  http://msdn.microsoft.com/xml/default.aspx? pull=/library/en- us/dnsql90/html/sql2k5xml.asp  http://msdn.microsoft.com/xml/default.aspx? pull=/library/en- us/dnsql90/html/sql2k5xmloptions.asp  http://msdn.microsoft.com/xml/default.aspx? pull=/library/en- us/dnsql90/html/sql25xmlbp.asp  MS Newsgroups, SQLJunkies.com, SQLTeam.com…and every SQL Server site  Contact me: denise.mcinerney@sqlpass.org