79a6f667830f9cf651f29243cb799c04.ppt
- Количество слайдов: 25
XML <? xml version="1. 0"? > <Book Edition=” 1”> <Title>Database systems</Title> <Author>Hector Garcia-Molina</Author> <ISBN>135 -383 -9038</ISBN> <Price>$100</Price> </Book>
XML Namespace <? xml version="1. 0"? > <Book Edition=” 1” xmlns=“http: //oak. cs. ucla. edu/cs 144”> <Title>Database systems</Title> <Author>Hector Garcia-Molina</Author> <ISBN>135 -383 -9038</ISBN> <Price>$100</Price> </Book>
Multiple Namespace <? xml version="1. 0"? > <Book Edition=” 1”> <Title>Database systems</Title> <Author>Hector Garcia-Molina</Author> <ISBN>135 -383 -9038</ISBN> <Price>$100</Price> </Book> • Book, Edition, Title, Author, ISBN: http: //oak. cs. ucla. edu/cs 144 • Price: http: //xml. com/shopping
Multiple Namespace <? xml version="1. 0"? > <Book Edition=” 1” xmlns=“http: //oak. cs. ucla. edu/cs 144”> <Title>Database systems</Title> <Author>Hector Garcia-Molina</Author> <ISBN>135 -383 -9038</ISBN> <Price>$100</Price> </Book>
Multiple Namespace <? xml version="1. 0"? > <Book Edition=” 1” xmlns=“http: //oak. cs. ucla. edu/cs 144” xmlns: s=“http: //xml. com/shopping”> <Title>Database systems</Title> <Author>Hector Garcia-Molina</Author> <ISBN>135 -383 -9038</ISBN> <s: Price>$100</s: Price> </Book>
Multiple Namespace <? xml version="1. 0"? > <Book o: Edition=” 1” xmlns=“http: //oak. cs. ucla. edu/cs 144” xmlns: s=“http: //xml. com/shopping” xmlns: o=“http: //oak. cs. ucla. edu/cs 144”> <Title>Database systems</Title> <Author>Hector Garcia-Molina</Author> <ISBN>135 -383 -9038</ISBN> <s: Price>$100</s: Price> </Book>
<a: E 1 xmlns: a=“http: //a. com/”> <b: E 2 xmlns: b=“http: //a. com/”> • Q: Do E 1 and E 2 belong to the same namespace?
<? xml version="1. 0"? > <Bookstore> <Book ISBN="0130353000" Price="$65" Ed="2 nd"> <Title>First Course in Database Systems</Title> <Author> <First_Name>Jeffrey</First_Name> <Last_Name>Ullman</Last_Name> </Author> </Book> <Book ISBN="0130319953" Price="$75"> <Title>Database Systems: Complete Book</Title> <Author>Hector Garcia-Molina</Author> <First_Name>Jeffrey</First_Name> <Last_Name>Ullman</Last_Name> </Author> <Remark>It's a great deal!</Remark> </Book> </Bookstore>
Tree Representation Bookstore Ed Title FC Book ISBN Book Price Author FN LN J U Title Author DS HGM ISBN Price Author FN LN J U Remark buy…
DTD <!ELEMENT Bookstore (Book*)> <!ELEMENT Book (Title, Author+, Remark? )> <!ATTLIST Book ISBN CDATA #REQUIRED Price CDATA #REQUIRED Ed CDATA #IMPLIED> <!ELEMENT Title (#PCDATA)> <!ELEMENT Author (#PCDATA| (First_Name, Last_Name))> <!ELEMENT Remark (#PCDATA)> <!ELEMENT First_Name (#PCDATA)> <!ELEMENT Last_Name (#PCDATA)>
Alternative Representation? Bookstore Ed Book ISBN Price Book Authors ISBN Price Authors Author Title Remark HGM FC DS buy… Author FN LN J U
Add reference to the authors <? xml version="1. 0"? > (IDREF type attribute) <Bookstore> <Book ISBN="0130353000" Price="$65" Ed="2 nd"> <Title>A First Course in Database Systems</Title> </Book> <Book ISBN="0130319953" Price="$75"> <Title>Database Systems: Complete Book</Title> <Remark>It's a great deal!</Remark> </Book> <Author>Hector Garcia-Molina</Author> <Author> <First_Name>Jeffrey</First_Name> <Last_Name>Ullman</Last_Name> </Author> </Bookstore> Assign a unique “key” to each author (ID type attribute)
Adding Keys <Author>Hector Garcia-Molina</Author> <Author> <First_Name>Jeffrey</First_Name> <Last_Name>Ullman</Last_Name> </Author>
Adding Keys <Author Ident=“HG”>Hector Garcia-Molina</Author> <Author Ident=“JU”> <First_Name>Jeffrey</First_Name> <Last_Name>Ullman</Last_Name> </Author>
Adding References <Book ISBN="0130353000" Price="$65” Ed="2 nd"> <Title>A First Course in Database Systems</Title> </Book> <Book ISBN="0130319953" Price="$75"> <Title>Database Systems: The Complete Book</Title> <Remark>It's a great deal!</Remark> </Book>
Adding References <Book ISBN="0130353000" Price="$65“ Ed="2 nd“ Authors=“JU”> <Title>A First Course in Database Systems</Title> </Book> <Book ISBN="0130319953" Price="$75" Authors=“HG JU”> <Title>Database Systems: The Complete Book</Title> <Remark>It's a great deal!</Remark> </Book>
Specifying Keys and References in DTD <!ELEMENT Bookstore (Book*, Author*)> <!ELEMENT Book (Title, Remark? )> <!ATTLIST Book ISBN CDATA #REQUIRED Price CDATA #REQUIRED Edition CDATA #IMPLIED> <!ELEMENT Title (#PCDATA)> <!ELEMENT Remark (#PCDATA)> <!ELEMENT Author (#PCDATA| (First_Name, Last_Name))> <!ELEMENT First_Name (#PCDATA)> <!ELEMENT Last_Name (#PCDATA)>
Specifying Keys and References in DTD <!ELEMENT Bookstore (Book*, Author*)> <!ELEMENT Book (Title, Remark? )> <!ATTLIST Book ISBN CDATA #REQUIRED Price CDATA #REQUIRED Edition CDATA #IMPLIED> <!ELEMENT Title (#PCDATA)> <!ELEMENT Remark (#PCDATA)> <!ELEMENT Author (#PCDATA| (First_Name, Last_Name))> <!ATTLIST Author Ident ID #REQUIRED> <!ELEMENT First_Name (#PCDATA)> <!ELEMENT Last_Name (#PCDATA)>
Specifying Keys and References in DTD <!ELEMENT Bookstore (Book*, Author*)> <!ELEMENT Book (Title, Remark? )> <!ATTLIST Book ISBN CDATA #REQUIRED Price CDATA #REQUIRED Edition CDATA #IMPLIED Authors IDREFS #REQUIRED> <!ELEMENT Title (#PCDATA)> <!ELEMENT Remark (#PCDATA)> <!ELEMENT Author (#PCDATA| (First_Name, Last_Name))> <!ATTLIST Author Ident ID #REQUIRED> <!ELEMENT First_Name (#PCDATA)> <!ELEMENT Last_Name (#PCDATA)>
XML Schema Example XML document <? xml version=“ 1. 0”? > <Book>Web App</Book>
Example DTD <!ELEMENT Book (Title, Author+, Remark? )> <!ELEMENT Title (#PCDATA)> <!ELEMENT Remark (#PCDATA)> <!ELEMENT Author (#PCDATA)> <!ATTLIST Book ISBN CDATA #REQUIRED Edition CDATA #IMPLIED>
key/keyref Example <Bookstore> <Book><ISBN>103</ISBN></Book> <Book><ISBN>104</ISBN></Book> <Review isbn=” 103”>Great!</Review> </Bookstore> • ISBN value should be unique among all Books • Review’s isbn attribute is a foreign key to Book ISBN
XPath Example <AAA> <BBB aaa="111" bbb="222"> <CCC/> <CCC xxx="555" yyy="666" zzz="777"/> </BBB> <BBB aaa="999"> <CCC xxx=“ww"/> <DDD xxx="ww"> <CCC>35</CCC> <EEE/> </DDD> </BBB> <BBB/> </AAA>
XML to Relation (1) <!ELEMENT Book (Title, Author, Remark)> <!ELEMENT Title (#PCDATA)> <!ELEMENT Author (First_Name, Last_Name, Bio)> <!ELEMENT First_Name (#PCDATA)> <!ELEMENT Last_Name (#PCDATA)> <!ELEMENT Bio (#PCDATA)> <!ELEMENT Remark (#PCDATA)> <!ATTLIST Book ISBN CDATA #REQUIRED Price CDATA #REQUIRED>
XML to Relation (2) <!ELEMENT Book (Title, Author+, Remark*)> <!ELEMENT Title (#PCDATA)> <!ELEMENT Author (First_Name, Last_Name, Bio)> <!ELEMENT First_Name (#PCDATA)> <!ELEMENT Last_Name (#PCDATA)> <!ELEMENT Bio (#PCDATA)> <!ELEMENT Remark (#PCDATA)> <!ATTLIST Book ISBN CDATA #REQUIRED Price CDATA #IMPLIED>
79a6f667830f9cf651f29243cb799c04.ppt