250 likes | 274 Views
This book provides a comprehensive guide to database systems, covering various topics such as design, implementation, and management. It is authored by Hector Garcia-Molina.
E N D
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/cs144”> <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/cs144 • Price: http://xml.com/shopping
Multiple Namespace <?xml version="1.0"?> <Book Edition=”1”xmlns=“http://oak.cs.ucla.edu/cs144”> <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/cs144” 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/cs144” xmlns:s=“http://xml.com/shopping” xmlns:o=“http://oak.cs.ucla.edu/cs144”> <Title>Database systems</Title> <Author>Hector Garcia-Molina</Author> <ISBN>135-383-9038</ISBN> <s:Price>$100</s:Price> </Book>
<a:E1 xmlns:a=“http://a.com/”> <b:E2 xmlns:b=“http://a.com/”> • Q: Do E1 and E2 belong to the same namespace?
<?xml version="1.0"?> <Bookstore> <Book ISBN="0130353000" Price="$65" Ed="2nd"> <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> <Author> <First_Name>Jeffrey</First_Name> <Last_Name>Ullman</Last_Name> </Author> <Remark>It's a great deal!</Remark> </Book> </Bookstore>
ISBN ISBN Price Price Ed Tree Representation Bookstore Book Book Title Author Title Author Author Remark FC FN LN DS HGM FN LN buy… J U J U
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)>
Ed ISBN ISBN Price Price Authors Alternative Representation? Bookstore Book Book Author Author Authors Title Title Remark HGM FN LN FC DS buy… J U
Add reference to the authors (IDREF type attribute) Assign a unique “key” to each author (ID type attribute) <?xml version="1.0"?> <Bookstore> <Book ISBN="0130353000" Price="$65" Ed="2nd"> <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>
<Author>Hector Garcia-Molina</Author> <Author> <First_Name>Jeffrey</First_Name> <Last_Name>Ullman</Last_Name> </Author> Adding Keys
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="2nd"> <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="2nd“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>