Presentation is loading. Please wait.

Presentation is loading. Please wait.

Creating Data Schemas Presentation by Chad Borer 2/6/2006.

Similar presentations


Presentation on theme: "Creating Data Schemas Presentation by Chad Borer 2/6/2006."— Presentation transcript:

1 Creating Data Schemas Presentation by Chad Borer 2/6/2006

2 To be covered  Overview of the data schema  Starting your Schema the right way  The Root Element  Parent Elements  Child Elements  Attributes and Restrictions  Ending your Schema the right way

3 Overview of a Data Schema  An XML Schema is simply a tree structure defining a relational database  As far as functionality goes, it is much like a relational data model  In each, one can find descriptions of each object in the database as well as the relations between them. Also, both place restrictions of the data that is entered

4 Overview of a Data Schema Root Element Parent Element(s) Child Element(s) Attributes MovieDatabase Genre Movie Actor Birthday

5 Overview of a Data Schema XML Declaration ( <?xml version="1.0“…) Namespace declaration ( <xsd:schema xmlns:…) Root Element Parent Elements / Child Elements / Attributes

6 XML Declaration  Always this one line on every data schema: * Because it is always the same, you can always copy this from an existing schema

7 XML Namespaces  The Namespace of a schema consists of the lines of code that come after the XML Declaration and before the actual data structure.  They’re the ones you have no idea how to write unless you copy them, and they look like they make absolutely no sense.

8 XML Namespaces Purposes of Namespaces  To link the Schema to a standard put out by the W3 Group  To declare each Schema as its own when more than one data Schema is used by an XML file  To force the XML file pointing to the Schema to declare each Namespace in the Schema within itself (confusing, but not necessary to understand right now)

9 XML Namespaces “xsd:schema” – Begins the ‘Schema’ “xmlns:xsd=“…” – Binds this Schema with the W3 standard elementFormDefault=“…” – XML representation attribute

10 Entities in General Simple v. Complex Types If an entity only has one value associated with it, it is said to be a simple type, otherwise it is known as a complex type. Not the same as Parent and Child elements

11 Entities in General Here is the general structure of a complextype entity in an XML Schema: attributes and/or child elements The exception is the Root Element.

12 Entities in General Don’t confuse the name of the entity and its type. When a child element is included in the description of its parents element, it is given a name and a type associated with it. It is important to distinguish the two apart especially when dealing with stylesheets. You will see this exemplified in the slide after next.

13 The Root Element  The root element is the object under which all the other ones can be grouped. For example, if you wanted to write a Schema for a movie theater, the movie theater itself is the root element.  If you wanted to write a Schema for a bunch of cars, you would need to find a root element such as Manufacturer or Dealership

14 The Root Element <xsd:element name="Genre" type="GenreType“ minOccurs="1" maxOccurs="unbounded"/>

15 The Root Element There can only be one element defined for a Schema and this is it. The name of the element is contained within the quotation marks. All references in XML files or Stylesheets will use this name

16 The Root Element Just following the tree structure of the Schema. The Root Element is a complexType because it has child elements.

17 The Root Element <xsd:element name="Genre" type="GenreType“ minOccurs="1" maxOccurs="unbounded"/> This is the First parent element in the Schema. The element’s name is “Genre” and all references will go to “Genre”. It is of the GenreType type which assumes the GenreType is defined later in the Schema

18 The Root Element Finishes the tree structure of the Root Element

19 Parent Elements

20 Parent Elements The child element “MovieType” is why a GenreType is a parent element.

21 Child Elements

22 Attributes and Restrictions An attribute is an entity of a simple type, meaning it had only one value. This particular attribute is of type “string” derived from the W3 group’s standard Schema as indicated by “xsd:string”.

23 Attributes and Restrictions  AnyURI  Boolean  Byte  Date  DateTime  Decimal  Double  Duration  Float  gDay  gMonth  gMonthDay  gYear  gYearMonth The W3 standard Schema’s many simple-type attributes  gID  IDREF  IDREFS  Int  Integer  Long  String And more

24 Attributes and Restrictions Restrictions on simpletypes are common and can be very helpful in making sure data integrity stays high. This child element is listed in ActorType and refers to the type “ssnType” which is not included in the W3 standard Schema. Although you cannot see it here, it is based on a “String”

25 Attributes and Restrictions When placing a restriction on a simple type, a whole new simple type must be created.

26 Attributes and Restrictions  Enumeration  FractionDigits  Length  MaxExclusive  MaxInclusive  MaxLength  MinExclusive  MinInclusive  Minlength  Pattern  TotalDigits  whiteSpace More about these restrictions if you search Google for xml restriction reference

27 Ending your Schema  Go back through your Schema and make sure each line of all your elements has been closed with either a “/>” at the end of the line, or a at the end of the coding block.  Last thing to include is  You’re done!

28 Questions?  Overview of the data schema  Starting your Schema the right way  The Root Element  Parent Elements  Child Elements  Attributes and Restrictions  Ending your Schema the right way

29 Assignment A.Draw out a data schema with 4 entities following the tree structure and include attributes for each entity. B.Create a well-formed data schema for the model you drew. C.Add 3 restrictions to any of the entities created in your schema. Good ones would include enumeration, pattern, and one of the min/max restrictions


Download ppt "Creating Data Schemas Presentation by Chad Borer 2/6/2006."

Similar presentations


Ads by Google