XML Documents - Database Design - Lecture Slides, Slides of Database Management Systems (DBMS)

This lecture slide is very easy to understand and very helpful to built a concept about the foundation of computers and Database Design.The key points in these slides are:Xml Documents, Relational Data Model, Xpath, Xquery, Extensible Markup Language, Manipulate Data Elements, Standard Generalized Markup Language, Standard Generalized Markup Language, Types of Xml Databases, Internal Model

Typology: Slides

2012/2013

Uploaded on 04/27/2013

asavari
asavari 🇮🇳

4.7

(15)

93 documents

1 / 24

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
XML and The Relational Data Model
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download XML Documents - Database Design - Lecture Slides and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

XML and The Relational Data Model

Overview

Define XML

XML model vs. relational model

XML Documents

Xpath

XQuery

Going from XML to the relational model

Why XML for databases?

One of the main reasons that XML was developed was to allow the

exchange of semi-structured documents, like invoices, order forms,

applications, etc., over the internet.

Using a database system to store XML documents allows users to be

able to better access information.

XML is also very flexible

Data is maintained in a self-describing format to accommodate a

variety of ever-evolving business needs.

There are two major types of XML databases:

XML-enabled. These map all XML to a traditional database (such as a

database), accepting XML as input and rendering XML as output.

Native XML (NXD) The internal model of such databases depends on

XML and uses XML documents as the fundamental unit of storage.

What is an XML Database?

Simply a database that stored XML Documents

Relational Model

Order of rows is not guaranteed unless the ORDER clause is

used in one or more columns

Relations (tables)

Data is represented in n-ary relations.

Has a domain that represents a set of values

Attributes (columns)

Strict schema

Restrictive

The strict schema insures data integrity

XML Model

The XML Model is hierarchical format Data is represented in trees structures There's nodes Relationships between the node

The schema provides flexibility

Easily modified format

XML Document Rules

XML documents must be well formated, meaning that every opening tag

needs a closing tag (ex. )

It allows users to define their own tags (unlike HTML)

The XML tags need to be properly nested.

The XML and xml tags are reserved for XML tags only.

You can use <-- XXX --> symbols for comments

XML is case sensitive so, is not the same as

Two types of XML documents commonly used, Document Type Definition

(DTD) or an XML Schema Definitions (XSD)

What is a Document Type Definition?

DTDs can be declared inline of the XML code or can reference an

external file

It provides the composition of the database's logical model and

defines the syntax rules or valid tags for each type of XML document.

A DTD is a file that has a .dtd extension.

This file describes XML elements.

Example of a DTD on next slide.......

What is an XML Schema Definition?

The XML Schema is an advance definition language that is used to describe the structure (elements, data types, relationships types, ranges, and default values)

It is an alternative to DTD

Since data types are allowed data validation is possible and easier to

do.

A XSD file has a .xsd extension

Example of a XSD on next slide.......

<xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>

</xs:schema>

XPath

Xpath is a language used to extract parts of an XML document.

XPath uses path expressions to navigate in XML documents

Xpath has 7 kinds of nodes:

Element Attribute Text Namespace Processing-Instruction Comment Document(root)

Harry Potter J K. Rowling 2005 29.99

Document node

Element node

Attribute node

Example of an XPath expressions:

/bookstore Will select the root element bookstore /bookstore/book Selects all book elements that are children of bookstore

Examples of XPath

Everyday Italian Giada De Laurentiis 2005 30.00

Example of an XQuery expressions:

doc("books.xml")/bookstore/book/title

Will return:

Everyday Italian

Example of XQuery

for: Iterates through a sequence, bind variable to items let: binds a variable to a sequence where:eliminates items of the iteration order by: reorders items of the iteration return: constructs query results

The XQuery FLWOR

Example of a XQuery expression:

for $x in doc("books.xml")/bookstore/book where $x/price> return $x/title

Will return:

Everyday Italian