Presentation is loading. Please wait.

Presentation is loading. Please wait.

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-1 COS 236 Day 23.

Similar presentations


Presentation on theme: "DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-1 COS 236 Day 23."— Presentation transcript:

1 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-1 COS 236 Day 23

2 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-2 Agenda Assignment 9 Graded –2 B’s, 5 C’s Assignment 10 Due Today Assignment 11 Posted –Due May 3 Assignment 12 Posted –Due May 9 Last Capstone Progress Reports Due Today Today we will discuss –XML and ADO.NET –Support-Files-Chap-13-XMLSupport-Files-Chap-13-XML

3 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-3 End of days? (subject to change) April 26 –DP Chapter 13 –Assignment 10 due April 30 –DP Chap 13 May 3 –DP Chap 15 –Assignment 11 Due –Review May 9 –Assignment 12 due –Quiz 3 –10 AM –Capstone presentations

4 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-4 David M. Kroenke’s Chapter Thirteen: XML and ADO.NET Part One Database Processing: Fundamentals, Design, and Implementation

5 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-5 Introduction Database processing and document processing need each other. –Database processing needs document processing for transmitting database views. –Document processing needs database processing for storing and manipulating data. As Internet usage increases, organizations want to make their Web pages more functional by displaying and updating data from organizational databases.

6 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-6 XML XML, or Extensible Markup Language, was 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 (which formerly stood for Simple Object Access Protocol but is now just a name instead of an acronym) is an XML-based standard protocol for sending messages of any type, using any protocol over the Internet.

7 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-7 XML (Continued) 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.

8 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-8 XML DTD An XML document consists of two sections: –Document Type Declaration (DTD). The DTD begins with DOCTYPE –Document data. An XML document can be: –Type-valid if the document conforms to its DTD. –Well-formed and not type-valid, if It violates the structure of its DTD, or It has no DTD. A DTD may be stored externally so many documents can be validated against the same DTD.

9 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-9 XMLSpy The diagrams in the text and in the following slides were prepared with Altova’s XMLSpy. Altova’sXMLSpy There is a 30 trial version of XMLSpy 2007 available at: http://www.altova.com/download.html http://www.altova.com/download.html

10 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-10 XML Document with Internal DTD Support-Files-Chap-13-XML\Figure 13-1.xml

11 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-11 XML Document with External DTD Support-Files-Chap-13-XML\Figure 13-2.xml

12 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-12 External DTD for CustomerList

13 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-13

14 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-14 XML Document with Two Customers Support-Files-Chap-13-XML\Figure 13-3.xml

15 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-15 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 procedures, 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 documents into another format.

16 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-16 Example XSL Stylesheet

17 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-17 Example HTML in Browser

18 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-18 David M. Kroenke’s Database Processing Fundamentals, Design, and Implementation (10 th Edition) End of Presentation: Chapter Thirteen Part One

19 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-19 David M. Kroenke’s Chapter Thirteen: XML and ADO.NET Part Two Database Processing: Fundamentals, Design, and Implementation

20 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-20 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 the schema maintained by W3C.

21 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-21 XML Schema Document

22 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-22 Schema-Valid XML Document

23 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-23 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.

24 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-24 Flat Schemas: XML Schema Flat schemas have all elements at the same level:

25 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-25 Flat Schemas: Schema-Valid Document

26 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-26 Flat Schemas: SGraphical Representation of Schema

27 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-27 Structured Schemas: XML Schema Structured schemas have defined subgroups:

28 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-28 Structured Schemas: Schema-Valid Document

29 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-29 Structured Schemas: Graphical Representation of Schema

30 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-30 David M. Kroenke’s Database Processing Fundamentals, Design, and Implementation (10 th Edition) End of Presentation: Chapter Thirteen Part Two

31 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-31 David M. Kroenke’s Chapter Thirteen: XML and ADO.NET Part Three Database Processing: Fundamentals, Design, and Implementation

32 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-32 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.

33 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-33 Global Elements : XML Schema with Global PhoneType

34 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-34 Global Elements : PhoneType Global Element

35 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-35 Global Elements : Graphical Representation of Schema

36 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-36 Creating XML Documents from Database Data Both Oracle and SQL Server can generate XML documents from database data. For Oracle — Use http://www.oracle.com/technology/tech/xml/xdkh ome.html http://www.oracle.com/technology/tech/xml/xdkh ome.html For SQL Server: –SELECT... FOR XML SELECT … FOR XML RAW — Places the values of columns as attributes in the XML document. SELECT … FOR XML AUTO, ELEMENTS — Places the values of columns as elements in the XML document. SELECT … FOR XML EXPLICIT — Allows the designation of which values of columns become attributes and elements. XML Spy can generate schemas from such output.

37 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-37 XML Schema with Multivalue Paths Some views cannot be created in a single SQL statement because the construct requires two or more multivalued paths. XML does not have this limitation. An XML document can have as many multivalued paths as necessary.

38 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-38 Multivalue Paths: XML Schema with Two Multivalued Paths

39 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-39 Multivalue Paths: Graphical View of the Schema

40 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-40 Industries with XML Industry Standards http://www.xml.org/

41 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-41 Industries with XML Industry Standards (Continued)

42 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-42 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 or process 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.

43 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-43 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

44 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-44 Additional XML Standards (Continued) 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

45 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-45 David M. Kroenke’s Database Processing Fundamentals, Design, and Implementation (10 th Edition) End of Presentation: Chapter Thirteen Part Three

46 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-46 David M. Kroenke’s Chapter Thirteen: XML and ADO.NET Part Four Database Processing: Fundamentals, Design, and Implementation

47 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-47 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 OLE DB facilitates the transformation of XML documents to and from database constructs. It uses datasets, which are in-memory, fully- functioned, independent databases.

48 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-48 Role of ADO.NET ADO.NET serves as an intermediary between all types of.NET applications and the DBMS and database:

49 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-49 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.

50 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-50 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.

51 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-51 Data Provider Components (Continued)

52 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-52 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 products.

53 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-53 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.

54 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-54 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.

55 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-55 ADO.NET: Creating the Dataset, Connection, and Data Adapter

56 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-56 ADO.NET: Using the Data Adapter to Fill the Dataset Tables

57 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-57 ADO.NET: Building Relationships

58 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-58 ADO.NET: Creating Referential Integrity Constraints

59 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-59 ADO.NET: Adding a Computed Column to a Data Table

60 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-60 ADO.NET: Using Data Grids – Filling the Grids with Dataset Tables

61 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-61 ADO.NET: Using Data Grids — Grid Display in Brower

62 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-62 David M. Kroenke’s Chapter Thirteen: XML and ADO.NET Part Five Database Processing: Fundamentals, Design, and Implementation

63 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-63 ADO.NET: Code to Generate an XML Document from the Dataset

64 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-64 ADO.NET: Portion of XML Document Generated from the Dataset

65 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-65 ADO.NET: Code to Generate an XML Schema from the Dataset

66 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-66 ADO.NET: Portion of XML Schema Generated from the Dataset

67 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-67 ADO.NET: Updating a Dataset and Database — Update Code

68 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-68 ADO.NET: Updating a Dataset and Database — Trigger-Like Event

69 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-69 ADO.NET: Updating a Dataset and Database Display RowVersion Code

70 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-70 ADO.NET: Updating a Dataset and Database Creating the Update Command

71 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-71 ADO.NET: Updating a Dataset and Database Log Showing Dataset Updates

72 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-72 ADO.NET: Updating a Dataset and Database Dataset Tables after Update

73 DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-73 David M. Kroenke’s Database Processing Fundamentals, Design, and Implementation (10 th Edition) End of Presentation: Chapter Thirteen Part Five


Download ppt "DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 13-1 COS 236 Day 23."

Similar presentations


Ads by Google