Chapter 9 - SQL/XML Flashcards
1
Q
What is the motivation and the different scenarios of SQL/XML integration?
A
- goals: flexible exchange between relational data and XML, reliable XML management
- > native XML DBMS not mature enough
- simple reuse of OR capabilities is not sufficient
- > LOBs for XML storate: coarse granularity
- > decompose into tables: complex and inefficient
- hybrid relational /XML data management: storage, acces, query, APIs
- > view/ access relational as XML/ XML as relational
2
Q
Overview: XML Data Type
A
- built-in SQL type for XML -> instances of XQuery Data Model
- > optimized internal representation
- > used in SQL/XML functions / store XML fragments in columns
- allows restrictions of XML value: XML(SEQUENCE), XML(DOCUMENT), XML(CONTENT)
- conversion from/to character string/BLOB: XMLPARSE( ), XMLSERIALIZE( )
3
Q
Overview: XMLCAST to convert between XML and SQL
A
- SQL -> XML : SQL predefined type value to XQuery atomic
- XML -> SQL: atomic or nodes (fn:data) to SQL types
- parse and serialize convert between node and sql varchar
4
Q
Overview: Schema and Validation
A
- Register schema in the DBMS for further referencing
- fnction XMLVALIDATE ( ACCORDING TO XMLSCHEMA ID )
- > annotates xml values and validate them
5
Q
Overview: Constructor functions
A
- Generating values of XML data type within SQL
- > one function for each node kind: XMLELEMENT, XMLATTRIBUTE, XMLTEXT…
- > sequence of values: XMLFOREST, XMLCONCAT
- > aggregation over sets of tuples: XMLAGG
- functions take content as arguments, alloing arbitrary nesting
- XMLAGG: used in combination with GROUP BY, evaluate content exprssion
- > produces a sequence of XML values, one for each row in the group
- > optional ORDER BY
- Dynamic retrieval of SQL data into XML -> publishing relational data as XML
6
Q
How can XML data be manipulated in SQL?
A
XQUERY support:
- Inverse of constructors: publish XML as relational
- extract portions of XML data stored in DBMS
XML Query function: evaluates XQuery expression
- > argument passing: SQL values inside the query (also XML data type)
- -> Use XQuery vars (e.g. $dept) with PASSING BY REF as dept
-> returns sequence
XMLTABLE function: transofrms XML data into table format
- > ROW pattern: XQuery expression, path item in result sequence will be a row
- > Column pattern: extract values from row item using path expressions
- > XMLQUERY syntax, with additional COLUMNS ( PATH )
Predicates on XML type: IS DOCUMENT, IS CONTENT, IS VALID, XMLEXISTS
7
Q
How does the mapping of an SQL schema to XML work?
A
TABLES: approach are single element and sequence of elements
- > to map schema or catalog, use its name as root node, with tables inside
- > produces XML document with table contents + XML schema