Download No Slide Title

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

Extensible Storage Engine wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Database wikipedia , lookup

Clusterpoint wikipedia , lookup

Relational model wikipedia , lookup

Database model wikipedia , lookup

Transcript
VICTORIA UNIVERSITY OF WELLINGTON
Te Whare Wananga o te Upoko o te Ika a Maui
Query Data Model
Lecturer : Dr. Pavle Mogin
SWEN 432
Advanced Database Design and
Implementation
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
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
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)
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
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 enodes and a-nodes, and
– zero or more i-nodes, c-nodes, and t-nodes
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 tnodes),
– Attributes (a-nodes), which belong to it, but are not its
children
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
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
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 e1 has a smaller and the right sibling
has a greater id value than e1
• This way is the document order established
SWEN 432 Advanced Database Design and Implementation 2015
Query Data Model 10
Document students.xml
<?xml version = "1.0" standalone = "yes"?>
<students>
<student sid = "s1">
<name>James</name>
<surname>Bond</surname>
</student>
<student sid = "s2">
<name>Roger</name>
<surname>Smith</surname>
</student>
<student sid = "s3">
<name>Emmy</name>
<surname>Smith</surname>
</student>
</students>
Query Data Model 11
SWEN 432 Advanced Database Design and Implementation 2015
Query Data Model Tree of students.xml
e2
sid name
a1
e3
student
d1
students.xml
e1
students
e5
student
s1
a2
e6
e7
a3
student
name surname
name surname sid
surname sid
e4
e8
e9
e10
t5
t6
s3
s2
t1
t2
t3
James
Bond
Roger
t4
Smith
Emmy
Smith
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
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
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
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, tnodes, 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