1 / 11

The One-to-many Relationship

The One-to-many Relationship. A relationship in which one object can reference several instances of another. Learning Objectives. Learn different techniques of implementing one-to-many relationships in XML Create custom data types in an XML schema

kioshi
Télécharger la présentation

The One-to-many Relationship

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The One-to-many Relationship A relationship in which one object can reference several instances of another.

  2. Learning Objectives • Learn different techniques of implementing one-to-many relationships in XML • Create custom data types in an XML schema • Create empty elements with attributes in an XML document • Build XML stylesheets using HTML style tags

  3. Implementing a One-to-ManyRelationship • Containment relationships • Example: <Team> <Name>Bulldogs</Name> <Player> <Name>Mike</Name> </Player> <Player> <Name>Vick</Name> </Player> </Team>

  4. Implementing a One-to-ManyRelationship • Intra-document relationships • Example: <Teams> <Team id="d1"> <Name>Bulldogs</Name> </team> <Team id="d2"> <Name>Yellow Jackets</Name> </team> </teams> <Players> <Player TeamRef="d1"> <Name>Mike</Name> </Player> <Player TeamRef="d2"> <Name>Vick</Name> </Player> </Players>

  5. Implementing a One-to-ManyRelationship • Inter-document relationships • Different tables may be located in different documents or files • Example: <Team id="d1"> <Name>Bulldogs</Name> </Team> <Team id="d2"> <Name>Yellow Jackets</Name> </Team> <Player> <Team href=";Team.xml#d1"/> <Name>Mike</Name> </Player> <Player> <Team href="Teams.xml#d2"/> <Name>Vick</Name> </Player>

  6. XML Schema Data Types • Basic data types • i.e. integer, boolean, string, decimal • Additional types • i.e. year, month, time, date, anyURI • Custom data types • Created by the user to define specific fields/values • Custom Data Type Example

  7. Regular Expression & Element Types • Perl’s regular expression language can be used to construct a pattern in defining an XML schema • Element Types • Element content • Root element; consists of elements only between tags • Mixed content element • Consists of text as well as other elements between tags • Single content element • Consists of only text between tags • Empty content element • Contains nothing between its opening and closing tags

  8. Attributes • Same naming structure as elements • In single element, attributes’ names must be unique • May not contain the “<“ symbol and the character string “&lt” can be used to represent it • Each attribute must have a name and a value • <hotelPicture filename="pook_hill_lodge.jpg" size="80" value="Image of Pook's Hill Lodge" imageURL="http://www.global-travel.co.uk/pook1.htm"/> • If quotes are used to enclose to enclose the string, they must differ from the quotes used to enclose the value. • <name familiar=“‘Jack’”>John Smith</name>

  9. XSL: Stylesheets • Using tables for layout • Also set background color, font-size, font-weight, and alignment using the style tag in HTML • Stylesheet

  10. Summary • Ways to implement a one-to-many relationship • Containment • Intra-document • Inter-document • Custom data types • Use built-in data types and apply restrictions, facets, or specific patterns • Empty element • Contains no text but may contain attributes for better element definition • Presentation layout with stylesheets • HTML style tags and table layout

  11. Exercise: Movie Database • Create an XML schema to depict a relationship between movie genres, movies, and actors/actresses • Choose two genres (drama, horror, action, etc.), two movies in each, and several actors/actresses from each. • Using the schema, create a document and populate it with the chosen information as well as additional actor/actress data including social security number in regex. • Create an XML stylesheet to present the data in table form for easier readability

More Related