Presentation is loading. Please wait.

Presentation is loading. Please wait.

VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Query Data Model Lecturer.

Similar presentations


Presentation on theme: "VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Query Data Model Lecturer."— Presentation transcript:

1 VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Query Data Model Lecturer : Dr. Pavle Mogin

2 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 1 Plan For Query Data Model What are two XML query languages we are interested for? What is the Query Data Model? Tree nodes of the Query Data Model Representing XML trees according to query data model Primary expressions: –Literals, –Variables –Redings: XQuery 1.0 and XPath 2.0 Data Model http://www.w3.org/TR/2004/xpath-datamodel

3 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 2 Two XML Query Languages There are several query languages proposed for use with XML so far: XPath, Lorel, XML-QL, Quilt, and XQuery XPath and XQuery are proposed by W3C, and XQuery uses XPath to navigate through XML documents XQuery is expected to play the same role within XML as SQL plays within relational data model XPath and XQuery share a specific common view on the XML data model and use the same primary expressions

4 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 3 What is the Query Data Model XPath and XQuery are the two XML query languages we are interested for that share a common view on the XML data model and use the same primary expressions Query Data Model offers an abstract representation of an XML document, or of a part of it: –Each XML document is a tree structure –There are seven kinds of tree nodes: Document node (d-node), Element node (e-node), Attribute node (a-node), Text node (t-node), Comment node (c-node), Processing Instruction node (i-node), and Name Space node (n-node)

5 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 4 Node Properties Each node has: –A unique identifier, –A name, and –A string value –A typed value Also, a node can have: –A parent node, –Children nodes, –Subordinated nodes, and The string value of a node is a sequence of all text values, owned by it or its descendants (including attributes) The typed value of a node can be derived from its string value and there is no great difference between these two

6 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 5 Properties of a Document Node A document node has: –An identifier, –A string value, –A typed value and can have the following directly subordinated nodes: –An e-node that, directly or indirectly contains all other e- nodes and a-nodes, and –zero or more i-nodes, c-nodes, and t-nodes

7 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 6 Properties of an Element Node An element node has: –An identifier, –A name, –A string value The string value of an empty element is an empty string “ ”” ” –A typed value: An empty element has an empty sequence “( )” as the typed value, A complex element having only elements as its content has an undefined typed value And may have: –Children and descendants (e-nodes, i-nodes, c-nodes, and t- nodes), –Attributes (a-nodes), which belong to it, but are not its children

8 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 7 Properties of an Attribute Node An attribute node has: –A name, –An identifier, –A string value, and –A typed value Each a-node has a parent, but an a-node is not a child of its parent

9 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 8 Properties of a Text Node A text node has: –An identifier, –A string value, and –A typed value Each t-node has a parent, which is ether a d-node, or an e-node A t-node is a child of its parent There may not exist two consecutive text nodes within the content of a parent, although a parent may own more than one t-node

10 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 9 About the Document Order Each node has its own unique identifier (id) Assignment of id values: –A separate space of id values is assigned to each document, –A separate space of id values is assigned to each kind of nodes within a document, –E-node children of a parent e-node have greater id values than their parent –Left sibling of an e-node e 1 has a smaller and the right sibling has a greater id value than e 1 This way is the document order established

11 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 10 Document students.xml James Bond Roger Smith Emmy Smith

12 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 11 surname Query Data Model Tree of students.xml d1d1 students.xml e1e1 students e2e2 e5e5 student a1a1 t1t1 e3e3 e4e4 s1 sid James name t2t2 Bond surname t3t3 e6e6 e7e7 Roger name t4t4 Smith a2a2 s2 sid surname Emmy name Smith s3 sid a3a3 e8e8 e 10 t5t5 t6t6 e9e9

13 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 12 Primary Expressions Primary expressions are: –Literals, –Variables, –Context defining expression (./ ), and –Function calls A literal is a direct representation of an atomic value –Numeric literals (int, decimal, double precision), and –String literals –Examples: 56 is a literal of the type xs:integer 5.6 is a literal of the type xs:decimal “56” is a literal of the type xs:string

14 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 13 Sequences Query data model is based on one dimensional sequences A sequence is an ordering of concepts –A concept is either a tree node (of any kind), or an atomic value An atomic value does not have an identifier An empty sequence is used to represent a null value The comma operator “, ” concatenates two concepts into a new sequence Integer sequences can also be constructed using “ to ” operator

15 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 14 Variables and Function Calls Variables are names that start with the “$” sign A variable can be bound to a sequence and then used in an expression Function calls are expressions of the form: fn: function_name

16 SWEN 432 Advanced Database Design and Implementation 2015 Query Data Model 15 Summary XPath and XQuery share a common data model Query data model considers an XML document as a tree over: a d-node, e-nodes, a-nodes, c-nodes, t- nodes, i-nodes, and n-nodes Nodes have identifiers, where an owner node has smaller identifier value than its children, and that gives raise to the notion of document order Different documents have different identifier value spaces Primary expressions are: –Literals, –Variables Variable names are prefixed by a ”$” (dollar) sign Function calls are: fn: function_name


Download ppt "VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Query Data Model Lecturer."

Similar presentations


Ads by Google