35
Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

  • View
    221

  • Download
    4

Embed Size (px)

Citation preview

Page 1: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Fundamentals, Design, and Implementation, 9/e

Cos 346

Day 23

Page 2: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/2 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Agenda

Students Evaluations Assignment 9 Not Corrected yet

– Will have completed by Next Class Assignment 10 Posted

– Due April 26 Quiz 4

– May 6 10 AM – Chap 9, 10, 12, 13 & 15

Next Class. Thursday, April 22, maybe canceled/modified due to Chancellors visit. Check in WebCT for Updates.

Today – Discussion on OBDC, OLE DB, AD0 and ASP

Page 3: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Fundamentals, Design, and Implementation, 9/e

Chapter 13XML and ADO.NET

Page 4: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/4 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Introduction

Database processing and document processing need each other– Database processing needs document

processing for expressing database views– Document processing needs database

processing for storing and manipulating data As Internet usage increased, organizations

wanted to make their Web pages more functional by displaying and updating data from organizational databases

Page 5: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/5 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

XML

XML, or Extensible Markup Language, developed in early 1990s– XML is a subset of SGML, or Standard Generalized

Markup Language Today XML is a hybrid of document processing

and database processing– It provides a standardized yet customizable way to

describe the content of documents– XML documents can automatically be generated from

database data, and vice versa SOAP is an XML-based standard protocol for

sending messages of any type, using any protocol over the Internet

Page 6: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/6 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

XML (cont.)

XML is used for describing, representing, and materializing database views

XML is better than HTML because – It provides a clear separation between document

structure, content, and materialization– It is standardized but allows for extension by developers– XML tags accurately represent the semantics of their

data Document Type Declarations (DTDs) and

XML Schemas can be used to describe the content of XML documents

Both Oracle and SQL Server can produce XML documents from database data

Page 7: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/7 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Example: XML Document

Page 8: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/8 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

XML DTD

XML document consists of two sections: – Document Type Declaration (DTD)

• The DTD begins with DOCTYPE <document_type_name>

– Document data

XML documents could be– Type-valid if the document conforms to its DTD– Well-formed and not be type-valid, because

• It violates the structure of its DTD

• It has no DTD

DTD may be stored externally so many documents can be validated against the same DTD

Page 9: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/9 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

XSLT

XSLT, or the Extensible Style Language may be used to materialize (transform) XML documents using XSL document– From XML documents into HTML or into XML in another

format XSLT is a declarative transformation language

– Declarative: create rules, not procedure, to materialize the document

– Transformational: transforms the input document into another document

XSLT uses stylesheets to indicate how to transform the elements of the XML document into another format

Page 10: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/10 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Example: External DTD

Page 11: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/11 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Example: XML Document

Page 12: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/12 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Example: XML HTML

Page 13: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/13 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Example: XML Browser

Page 14: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/14 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

XML Schema

XML Schema is a standard for describing the content of an XML document, i.e., defining custom vocabularies– Documents that conform to an XML Schema are called

schema-valid– An XML document can be well-formed and be neither

type-valid nor schema-valid

Unlike DTDs, XML Schema documents are themselves XML documents that can be validated against their schema maintained by W3C

Page 15: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/15 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Example: XML Schema

Page 16: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/16 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Example: XML Schema

Page 17: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/17 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Elements and Attributes

Schemas consist of elements and attributes– Elements are used to carry data and attributes

are used to carry metadata

Two types of elements:– Simple elements have a single data value– ComplexType elements can have one or more

simple or complexType elements• ComplexType elements can have attributes

Page 18: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/18 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Flat Schemas

Flat schemas have all elements at the same level

Page 19: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/19 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Structured Schemas

Structured schemas have defined subgroups

Page 20: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/20 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Global Elements

To eliminate the definition duplication, elements can be declared globally, i.e., reside at the top level of the schema, and then reused

Page 21: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/21 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Global Elements

Page 22: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/22 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Example XML Industry Standards

Accounting– Extensible Financial Reporting Markup Language (XFRML)

Architecture and Construction– Architecture, Engineering, and Construction XML (aecXML)

Automotive– Automotive Industry Action Group (AIAG)– XML for the Automotive Industry (SAE J2008)

Banking– Banking Industry Technology Secretariat (BITS)– Bank Internet Payment System (BIPS)

Electronic Data Interchange– Data Interchange Standards Association (DISA)– XML/EDI Group

Page 23: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/23 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Example XML Industry Standards (cont.) Human Resources

– Human Resources Markup Language (hrml) Insurance

– ACORD: Property and Casualty Real Estate

– Real Estate Listing Management System (OpenMLS)– Real Estate Transaction Standard (RETS)

Software– IBM– INRIA: Koala Bean Markup Language (KBML)– Open Software Description Format (OSD)

Workflow– Simple Workflow Access Protocol (SWAP) – Workflow Management Coalition (MfMC): Wf-XML

Page 24: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/24 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

ADO.NET

ADO.NET is a new, improved, and greatly expanded version of ADO that was developed for the Microsoft .NET initiative

It incorporates all of the functionality of ADO and facilitates the transformation of XML documents to and from database data

It uses datasets, which is an in-memory, fully-functioned, independent databases

Page 25: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/25 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Role of ADO.NET

ADO.NET serves as an intermediary between all types of .NET applications and the DBMS and database

Page 26: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/26 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Data Provider

A .NET data provider is a library of classes that provides ADO.NET services

Microsoft’s provides three data providers– OLE DB data provider can be used to process

any OLE DB-compliant data source– SQLClient data provider is purpose-built for use

with SQL Server– OracleClient data provider is purpose-built for

use with Oracle

Page 27: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/27 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Data Provider Components

Page 28: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/28 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Data Provider Components

A connection object is similar to the OBDC’s connection object

A command object is created on an established connection

A data reader provides read-only, forward-only, fast access to database data

An application can get and put data to and from the database using the command object

A dataset is an in-memory database that is disconnected from any regular database – It distinguishes ADO.NET from the previous data access

technology

Page 29: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/29 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

The ADO.NET Dataset

A dataset is an in-memory database that is disconnected from any regular database

Datasets can have – Multiple tables, views, and relationships

• Tables may have surrogate key (auto increment columns), primary keys, and be declared as unique

– Referential integrity rules and actions– The equivalent of triggers

Datasets may be constructed from several different databases and managed by different DBMS

Page 30: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/30 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Dataset Advantages

Dataset contents and its XML schema can be easily formatted as an XML document

Also, XML schema documents can be read to create the structure of the dataset, and XML documents can be read to fill the dataset

Datasets are needed to provide a standardized, non-proprietary means to process database views– This is important for the processing of views with multiple

multi-value paths

Page 31: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/31 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Dataset Disadvantages

Because dataset data are disconnected from regular database, only optimistic locking can be used when updating the regular database with the dataset

In the case of conflict, either the dataset must be reprocessed or the data change must be forced onto the database, causing the lost update problem

Thus, datasets cannot be used for applications in which optimistic locking is problematical– Instead, the ADO.NET command object should be used

Page 32: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/32 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

XML Standards

XML: Extensible Markup Language XSL: XSLT Stylesheet. The document that

provides the {match, action} pairs and other data for XSLT to use when transforming an XML document

XSLT: A program that applies XSLT Stylesheets to an XML document to produce a transformed XML document

XML schema: An XML-compliant language for constraining the structure of an XML document

Page 33: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/33 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Additional XML Standards

Xpath– A sublanguage within XSLT used to identify parts of an

XML document to be transformed– Can also be used for calculations and string manipulation

Xpointer– A standard for linking one document to another

SAX: Simple API (application program interface) for XML– An event-based parser that notifies a program when the

elements of an XML document have been encountered during document parsing

Page 34: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Chapter 13/34 Copyright © 2004

Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. Kroenke

Additional XML Standards (cont.) DOM: Document Object Model

– An API that represents an XML document as a tree– Each node of the tree represents a piece of the XML document– A program can directly access and manipulate a node of the DOM

representation Xquery

– A standard for expressing database queries as XML documents– The structure of the query uses XPath facilities, and the result of

the query is represented in an XML format XML Namespaces: A standard for allocating terminology to

defined collections– X:Name is interpreted as the element Name as defined in

namespace X– Useful for disambiguating terms

Page 35: Fundamentals, Design, and Implementation, 9/e Cos 346 Day 23

Fundamentals, Design, and Implementation, 9/e

Chapter 13XML and ADO.NET