Lecture 14: Relational Algebra Projects XML?Relational AlgebraSemijoinSemijoins in Distributed DatabasesComplex RA ExpressionsOperations on BagsTransitive ClosureXMLSlide 9Why XML is of Interest to UsXML Data Sharing and ExchangeFrom HTML to XMLHTMLSlide 14XML TerminologyMore XML: AttributesMore XML: Oids and ReferencesLecture 14:Relational AlgebraProjectsXML?February 7th, 2003Relational Algebra•Five operators:–Union: –Difference: -–Selection:–Projection: –Cartesian Product: •Derived or auxiliary operators:–Intersection, complement–Joins:•Natural join•Theta join•Equi-join•Semi-join –Renaming:Semijoin•R ⋉ S = A1,…,An (R ⋈ S)•Where A1, …, An are the attributes in R•Example:–Employee ⋉ DependentsSemijoins in Distributed Databases•Semijoins are used in distributed databasesSSN Name. . . . . .SSN Dname Age. . . . . .EmployeeDependentsnetworkEmployee ⋈ssn=ssn (age>71 (Dependents))Employee ⋈ssn=ssn (age>71 (Dependents))T = SSN age>71 (Dependents)R = Employee T⋉Answer = R ⋈ DependentsComplex RA Expressions Person Purchase Person Productname=fredname=gizmo pid ssnseller-ssn=ssnpid=pidbuyer-ssn=ssn nameOperations on BagsA bag = a set with repeated elementsAll operations need to be defined carefully on bags•{a,b,b,c}{a,b,b,b,e,f,f}={a,a,b,b,b,b,b,c,e,f,f}•{a,b,b,b,c,c} – {b,c,c,c,d} = {a,b,b,d}• C(R): preserves the number of occurrences• A(R): no duplicate elimination•Cartesian product, join: no duplicate eliminationImportant ! Relational Engines work on bags, not sets !Reading assignment: 5.3 – 5.4Transitive Closure•Can we compute “transitive closure”?•Find all direct and indirect relatives of FredName1 Name2 RelationshipFred Mary FatherMary Joe CousinMary Bill SpouseNancy Lou SisterXMLXML•eXtensible Markup Language•XML 1.0 – a recommendation from W3C, 1998•Roots: SGML (a very nasty language).•After the roots: a format for sharing dataWhy XML is of Interest to Us•XML is just syntax for data–Note: we have no syntax for relational data–But XML is not relational: semistructured•This is exciting because:–Can translate any data to XML–Can ship XML over the Web (HTTP)–Can input XML into any application–Thus: data sharing and exchange on the WebXML Data Sharing and Exchangeapplicationrelational dataTransformIntegrateWarehouseXML Data WEB (HTTP)applicationapplicationlegacy dataobject-relationalSpecific data management tasksFrom HTML to XMLHTML describes the presentationHTML<h1> Bibliography </h1><p> <i> Foundations of Databases </i> Abiteboul, Hull, Vianu <br> Addison Wesley, 1995<p> <i> Data on the Web </i> Abiteoul, Buneman, Suciu <br> Morgan Kaufmann, 1999<h1> Bibliography </h1><p> <i> Foundations of Databases </i> Abiteboul, Hull, Vianu <br> Addison Wesley, 1995<p> <i> Data on the Web </i> Abiteoul, Buneman, Suciu <br> Morgan Kaufmann, 1999XML<bibliography> <book> <title> Foundations… </title> <author> Abiteboul </author> <author> Hull </author> <author> Vianu </author> <publisher> Addison Wesley </publisher> <year> 1995 </year> </book> …</bibliography><bibliography> <book> <title> Foundations… </title> <author> Abiteboul </author> <author> Hull </author> <author> Vianu </author> <publisher> Addison Wesley </publisher> <year> 1995 </year> </book> …</bibliography>XML describes the contentXML Terminology•tags: book, title, author, …•start tag: <book>, end tag: </book>•elements: <book>…<book>,<author>…</author>•elements are nested•empty element: <red></red> abbrv. <red/>•an XML document: single root elementwell formed XML document: if it has matching tagsMore XML: Attributes<book price = “55” currency = “USD”> <title> Foundations of Databases </title> <author> Abiteboul </author> … <year> 1995 </year></book><book price = “55” currency = “USD”> <title> Foundations of Databases </title> <author> Abiteboul </author> … <year> 1995 </year></book>attributes are alternative ways to represent dataMore XML: Oids and References<person id=“o555”> <name> Jane </name> </person><person id=“o456”> <name> Mary </name> <children idref=“o123 o555”/></person><person id=“o123” mother=“o456”><name>John</name></person><person id=“o555”> <name> Jane </name> </person><person id=“o456”> <name> Mary </name> <children idref=“o123 o555”/></person><person id=“o123” mother=“o456”><name>John</name></person>oids and references in XML are just
View Full Document