Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exam II Syllabus uStorage & Buffer Management uIndexing: Btrees & Hash uMulti-dimensional Indexing uQuery processing (relational ops) uQuery optimization.

Similar presentations


Presentation on theme: "Exam II Syllabus uStorage & Buffer Management uIndexing: Btrees & Hash uMulti-dimensional Indexing uQuery processing (relational ops) uQuery optimization."— Presentation transcript:

1 Exam II Syllabus uStorage & Buffer Management uIndexing: Btrees & Hash uMulti-dimensional Indexing uQuery processing (relational ops) uQuery optimization 1

2 2 XML: Semi-structured Data Model Document Type Definitions XML Schema

3 3 Semistructured Data uA data model based on trees, as opposed to the relational model (based on tables) uMotivation: flexible representation of data. uMotivation: sharing of documents among systems and databases.

4 4 Graphs of Semistructured Data uNodes = objects. uLabels on arcs (like attribute names). uAtomic values at leaf nodes (nodes with no arcs out). uFlexibility: There is no restriction on wLabels out of a node. wNumber of successors with a given label.

5 5 Example: Data Graph Bud A.B. Gold1995 MapleJoe’s M’lob beer bar manf servedAt name addr prize yearaward root The bar object for Joe’s Bar The beer object for Bud Notice a new kind of data.

6 6 XML: Semi-structured Data uXML = Extensible Markup Language. uCaptures the same information as the semi-structured data graph uWhile HTML uses tags for formatting (e.g., “italic”), XML uses tags for semantics (e.g., “this is an address”). uKey idea: create tag sets for a domain (e.g., genomics), and translate all data into properly tagged XML documents.

7 7 Well-Formed and Valid XML uWell-Formed XML allows you to invent your own tags. uValid XML conforms to a certain Document Type Definition (DTD): like a schema

8 8 Well-Formed XML uStart the document with a declaration, surrounded by. uNormal declaration is:  “standalone” = “no DTD provided.” uBalance of document is a root tag surrounding nested tags.

9 9 Tags uTags are normally matched pairs, as …. uUnmatched tags also allowed, as uTags may be nested arbitrarily. uXML tags are case-sensitive.

10 10 Example: Well-Formed XML Joe’s Bar Bud 2.50 Miller 3.00 … … A NAME subelement A BEER subelement Root tag Tags surrounding a BEER element

11 11 DTD’s (Document Type Definitions) uA grammatical notation for describing allowed use of tags: like a schema  Definition form: [ ( )>... more elements... ]>

12 12 DTD Elements uThe description of an element consists of its name (tag), and a parenthesized description of any nested tags. wIncludes order of subtags and their multiplicity. uLeaves (text elements) have #PCDATA (Parsed Character DATA ) in place of nested tags.

13 13 Example: DTD <!DOCTYPE BARS [ ]> A BARS object has zero or more BAR’s nested within. A BAR has one NAME and one or more BEER subobjects. A BEER has a NAME and a PRICE. NAME and PRICE are text.

14 14 Element Descriptions uSubtags must appear in order shown. uA tag may be followed by a symbol to indicate its multiplicity. w* = zero or more. w+ = one or more. w? = zero or one. uSymbol | can connect alternative sequences of tags.

15 15 Example: Element Description uA name is an optional title (e.g., “Prof.”), a first name, and a last name, in that order, or it is an IP address: <!ELEMENT NAME ( (TITLE?, FIRST, LAST) | IPADDR )>

16 16 Use of DTD’s 1.Set standalone = “no”. 2.Either: a)Include the DTD as a preamble of the XML document, or b)Follow DOCTYPE and the by SYSTEM and a path to the file where the DTD can be found.

17 17 Example: (a) <!DOCTYPE BARS [ ]> Joe’s Bar Bud 2.50 Miller 3.00 … The DTD The document

18 18 Example: (b) uAssume the BARS DTD is in file bar.dtd. Joe’s Bar Bud 2.50 Miller 3.00 … Get the DTD from the file bar.dtd

19 19 Attributes uLike HTML, the opening tag in XML can have atttribute = value pairs. uAttributes also allow linking among elements (discussed later).

20 20 Attributes uOpening tags in XML can have attributes. uIn a DTD, declares attributes for element E, along with its datatype.

21 21 Example: Attributes  Bars can have an attribute kind, a character string describing the bar. Character string type; no tags Attribute is optional opposite: #REQUIRED

22 22 Example: Attribute Use uIn a document that allows BAR tags, we might see: Homma’s Sapporo 5.00...

23 23 Bars, Using Attributes … Notice Beer elements have only opening tags with attributes. name and price are attributes

24 24 Example: Attributes <!ATTLIST name CDATA #REQUIRED, price CDATA #IMPLIED> No closing tag or subelements Character string Required = “must occur”; Implied = “optional Example use:

25 25 ID’s and IDREF’s uAttributes can be pointers from one object to another. wCompare to HTML’s NAME = ”foo” and HREF = ”#foo”. uAllows the structure of an XML document to be a general graph, rather than just a tree.

26 26 Creating ID’s uGive an element E an attribute A of type ID. uWhen using tag in an XML document, give its attribute A a unique value. uExample:

27 27 Creating IDREF’s uTo allow elements of type F to refer to another element with an ID attribute, give F an attribute of type IDREF. uOr, let the attribute have type IDREFS, so the F -element can refer to any number of other elements.

28 28 Example: ID’s and IDREF’s uA new BARS DTD includes both BAR and BEER subelements.  BARS and BEERS have ID attributes name.  BARS have SELLS subelements, consisting of a number (the price of one beer) and an IDREF theBeer leading to that beer.  BEERS have attribute soldBy, which is an IDREFS leading to all the bars that sell it.

29 29 The DTD <!DOCTYPE BARS [ ]> Beer elements have an ID attribute called name, and a soldBy attribute that is a set of Bar names. SELLS elements have a number (the price) and one reference to a beer. Bar elements have name as an ID attribute and have one or more SELLS subelements. No Subelements

30 30 Example: A Document 2.50 3.00 … <BEER name = ”Bud” soldBy = ”JoesBar SuesBar …” /> …

31 31 Empty Elements uWe can do all the work of an element in its attributes. wLike BEER in previous example.  Another example: SELLS elements could have attribute price rather than a value that is a price.

32 32 Example: Empty Element uIn the DTD, declare: uExample use: Note exception to “matching tags” rule

33 33 XML Schema uA more powerful way to describe the structure of XML documents than DTDs uXML-Schema declarations are themselves XML documents. wThey describe “elements” and the things doing the describing are also “elements.”

34 34 Structure of an XML-Schema Document <xs:schema xmlns:xs = ”http://www.w3.org/2001/XMLschema”>... Defines ”xs” to be the namespace described in the URL shown. Any string in place of ”xs” is OK. So uses of ”xs” within the schema element refer to tags from this namespace.

35 35 The xs:element Element uHas attributes: 1.name = the tag-name of the element being defined. 2.type = the type of the element. uCould be an XML-Schema type, e.g., xs:string. uOr the name of a type defined in the document itself.

36 36 Example: xs:element <xs:element name = ”NAME” type = ”xs:string” /> uDescribes elements such as Joe’s Bar

37 37 Complex Types uTo describe elements that consist of subelements, we use xs:complexType. wAttribute name gives a name to the type. uTypical subelement of a complex type is xs:sequence, which itself has a sequence of xs:element subelements. wUse minOccurs and maxOccurs attributes to control the number of occurrences of an xs:element.

38 38 Example: a Type for Beers <xs:element name = ”NAME” type = ”xs:string” minOccurs = ”1” maxOccurs = ”1” /> <xs:element name = ”PRICE” type = ”xs:float” minOccurs = ”0” maxOccurs = ”1” /> Exactly one occurrence Like ? in a DTD

39 39 An Element of Type beerType Bud 2.50 We don’t know the name of the element of this type.

40 40 Example: Create Element of beerType <xs:element name = ”Beers” type = ”beerType” /> Bud 2.50 Now we know the name

41 41 Example: a Type for Bars <xs:element name = ”NAME” type = ”xs:string” minOccurs = ”1” maxOccurs = ”1” /> <xs:element name = ”BEER” type = ”beerType” minOccurs = ”0” maxOccurs = ”unbounded” /> Like * in a DTD

42 42 xs:attribute uxs:attribute elements can be used within a complex type to indicate attributes of elements of that type. uattributes of xs:attribute: wname and type as for xs.element. wuse = ”required” or ”optional”.

43 43 Example: xs:attribute <xs:attribute name = ”name” type = ”xs:string” use = ”required” /> <xs:attribute name = ”price” type = ”xs:float” use = ”optional” />

44 44 An Element of This New Type beerType <xxx name = ”Bud” price = ”2.50” /> We still don’t know the element name. The element is empty, since there are no declared subelements.

45 45 Restricted Simple Types uxs:simpleType can describe enumerations and range-restricted base types. uname is an attribute u xs:restriction is a subelement.

46 46 Restrictions uAttribute base gives the simple type to be restricted, e.g., xs:integer. uxs:{min, max}{Inclusive, Exclusive} are four attributes that can give a lower or upper bound on a numerical range. uxs:enumeration is a subelement with attribute value that allows enumerated types.

47 47 Example: license Attribute for BAR

48 48 Example: Prices in Range [1,5) <xs:restriction base = ”xs:float” minInclusive = ”1.00” maxExclusive = ”5.00” />

49 49 Keys in XML Schema uAn xs:element can have an xs:key subelement. uMeaning: within this element, all subelements reached by a certain selector path will have unique values for a certain combination of fields. uExample: within one BAR element, the name attribute of a BEER element is unique.

50 50 Example: Key...... XPath is a query language for XML. All we need to know here is that a path is a sequence of tags separated by /. And @ indicates an attribute rather than a tag.

51 51 Foreign Keys uAn xs:keyref subelement within an xs:element says that within this element, certain values (defined by selector and field(s), as for keys) must appear as values of a certain key.

52 52 Example: Foreign Key uSuppose that we have declared that subelement NAME of BAR is a key for BARS. wThe name of the key is barKey. uWe wish to declare DRINKER elements that have FREQ subelements. An attribute bar of FREQ is a foreign key, referring to the NAME of a BAR.

53 53 Example: Foreign Key in XML Schema <xs:element name = ”DRINKERS”... <xs:keyref name = ”barRef” refers = ”barKey”


Download ppt "Exam II Syllabus uStorage & Buffer Management uIndexing: Btrees & Hash uMulti-dimensional Indexing uQuery processing (relational ops) uQuery optimization."

Similar presentations


Ads by Google