Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML Many-to-Many Relationship January 30, 2006. Learning Objectives ● Create a schema for a data model containing a many:many relationship ● Understand.

Similar presentations


Presentation on theme: "XML Many-to-Many Relationship January 30, 2006. Learning Objectives ● Create a schema for a data model containing a many:many relationship ● Understand."— Presentation transcript:

1 XML Many-to-Many Relationship January 30, 2006

2 Learning Objectives ● Create a schema for a data model containing a many:many relationship ● Understand the purpose of and how to implement an XML include ● Define the format of displayed numeric values using an XML numeric function ● Define numeric elements using more specific data types

3 M:M Data Model A hotel can have many amenities, and an amenity can be at many hotels.

4 M:M Relationships in XML: Problem ● Many-to-many relationship is not supported directly by XML. ● Each element may only have a single parent element.

5 M:M Relationships in XML: Solutions ● Create XML documents that eliminate the need for a many-to-many relationship. – Create a separate XML doc for each entity. – Eliminate the need for a many-to-many relationship by creating two schemas. ● Represent the many-to-many relationship using unique identifiers. ● Discard the information that requires the many-to-many relationship.

6 Two 1:M Relationships ● How do you link schemas? – element:

7 Multiple Schemas: Advantages ● Ease of schema maintenance ● Improved schema readability ● Commonly occurring elements can be reused by other schemas.

8 Exercise 1: 1) Create a separate schema. 2) Link schemas with element.

9 Data Types for Schemas ● Previous chapters: – year – month – time – anyURI – date

10 More Schema Data Types http://www.xml.dvint.com/docs/SchemaDataTypesQR-2.pdf

11 Exercise 2: Data Types ● Use data type “positiveInteger” to describe data for: – City population – Hotel lower price – Hotel upper price

12 XSLT Functions ● Manipulate or format numeric data – Chapter 3, 1:M relationship: displays number of hotels within a city – Chapter 5, M:M relationship: format-number() function converts a numeric value into a string using specified patterns

13 XSLT Functions ● Format-number (number, pattern) – Number is the numeric value to be formatted – Pattern is a string that lays out the general representation of a number. Each character in the string represents either a digit from number or some special punctuation such as a comma or minus sign.

14 XSLT Functions

15 Other XSLT Functions

16 Exercise 3: XSLT Functions 1.Use format-number() function to display population to show digits grouped by three's, separated by a comma. 2.Use position() and last() functions to separate hotel amenities with a comma.

17 Summary ● To implement a m:m relationship in XML, it is necessary to break the relationship into two one-to- many type relationships. ● A schema designer may find it necessary to break the schema into separate files and link them using an include statement. ● Numeric elements can be more specifically described using data types that define the number type. ● Additional numeric functions can be used in the XML style sheet to manipulate or format numeric data.

18 M:M Chapter Exercise 1.Create two XML schemas to describe the illustrated data model. Include all of the attributes listed in the data model. 2.Create an XML document that includes at least two movies and two cast members per movie. 3.Create an XML style sheet to present the information in HTML format.


Download ppt "XML Many-to-Many Relationship January 30, 2006. Learning Objectives ● Create a schema for a data model containing a many:many relationship ● Understand."

Similar presentations


Ads by Google