Normal Forms, XML, and Schemas Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 13, 2005 Some slide content.

Slides:



Advertisements
Similar presentations
XML: Extensible Markup Language
Advertisements

1 Web Data Management XML Schema. 2 In this lecture XML Schemas Elements v. Types Regular expressions Expressive power Resources W3C Draft:
1 XML DTD & XML Schema Monica Farrow G30
SDPL 2003Notes 2: Document Instances and Grammars1 2.5 XML Schemas n A quick introduction to XML Schema –W3C Recommendation, May 2, 2001: »XML Schema Part.
Querying XML Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 6, 2003 Some slide content courtesy of Susan Davidson.
1 Lecture 10 XML Wednesday, October 18, XML Outline XML (4.6, 4.7) –Syntax –Semistructured data –DTDs.
Introduction to XLink Transparency No. 1 XML Information Set W3C Recommendation 24 October 2001 (1stEdition) 4 February 2004 (2ndEdition) Cheng-Chia Chen.
XML, XPath, and XQuery Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 18, 2005 Some slide content courtesy.
XML: Semistructured Data Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 2, 2003 Some slide content courtesy.
1 COS 425: Database and Information Management Systems XML and information exchange.
1 Administrivia  HW3 deadline extended: Tuesday 10/7  Revised upcoming schedule:  Thurs. 10/2: Querying XML  Tues. 10/7: More on XML; beginning of.
Winter 2002Arthur Keller – CS 18018–1 Schedule Today: Mar. 12 (T) u Semistructured Data, XML, XQuery. u Read Sections Assignment 8 due. Mar. 14.
Semi-structured Data. Facts about the Web Growing fast Popular Semi-structured data –Data is presented for ‘human’-processing –Data is often ‘self-describing’
1 Introduction to XML Yanlei Diao UMass Amherst April 19, 2007 Slides Courtesy of Ramakrishnan & Gehrke, Dan Suciu, Zack Ives and Gerome Miklau.
Fall 2001Arthur Keller – CS 18017–1 Schedule Nov. 27 (T) Semistructured Data, XML. u Read Sections Assignment 8 due. Nov. 29 (TH) The Real World,
Schema Refinement and Normalization Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 6, 2004 Some slide content.
XML, Schemas, and XPath Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 14, 2004 Some slide content courtesy.
XML Querying and Views Helena Galhardas DEI IST (slides baseados na disciplina CIS 550 – Database & Information Systems, Univ. Pennsylvania, Zachary Ives)CIS.
Schema Normalization, Concluded Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 11, 2005 Some slide content.
Applied Component-Based Software Engineering XML Basics
1 Advanced Topics XML and Databases. 2 XML u Overview u Structure of XML Data –XML Document Type Definition DTD –Namespaces –XML Schema u Query and Transformation.
XML Schemas and Queries Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems August 7, 2015.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
4/20/2017.
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Schema 1 Lecturer.
1 XML Schemas. 2 Useful Links Schema tutorial links:
Dr. Azeddine Chikh IS446: Internet Software Development.
Neminath Simmachandran
Semistructured data and XML CS 645 April 5, 2006 Some slide content courtesy of Ramakrishnan & Gehrke, Dan Suciu, Zack Ives.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
Company LOGO OODB and XML Database Management Systems – Fall 2012 Matthew Moccaro.
FIGIS’ML Hands-on training - © FAO/FIGIS An introduction to XML Objectives : –what is XML? –XML and HTML –XML documents structure well-formedness.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
Winter 2006Keller, Ullman, Cushing18–1 Plan 1.Information integration: important new application that motivates what follows. 2.Semistructured data: a.
XML A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault.
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
Of 33 lecture 3: xml and xml schema. of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema –
Indexing and Data Exchange Formats Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems October 17, 2015.
SDPL 2005Notes 2.5: XML Schemas1 2.5 XML Schemas n Short introduction to XML Schema –W3C Recommendation, 1 st Ed. May, 2001; 2 nd Ed. Oct, 2004: »XML Schema.
An OO schema language for XML SOX W3C Note 30 July 1999.
XML Instructor: Charles Moen CSCI/CINF XML  Extensible Markup Language  A set of rules that allow you to create your own markup language  Designed.
Web Servers, Data Transmission and Exchange Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems January 29, 2008.
ER Diagrams (Concluded), Schema Refinement, and Normalization Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October.
XML Schemas, XPath, and XQuery Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 19, 2004 Some slide content.
An Introduction to XML Sandeep Bhattaram
Semistructured Data Extensible Markup Language Document Type Definitions Zaki Malik November 04, 2008.
Management of XML and Semistructured Data Lecture 10: Schemas Monday, April 30, 2001.
The Semistructured-Data Model Programming Languages for XML Spring 2011 Instructor: Hassan Khosravi.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
When we create.rtf document apart from saving the actual info the tool saves additional info like start of a paragraph, bold, size of the font.. Etc. This.
XML Validation II Advanced DTDs + Schemas Robin Burke ECT 360.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Database design and normalization.
© 2016 A. Haeberlen, Z. Ives CIS 455/555: Internet and Web Systems 1 University of Pennsylvania XML (continued) February 10, 2016.
Querying XML, Part II Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems February 5, 2008.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
SEMI-STRUCTURED DATA (XML) 1. SEMI-STRUCTURED DATA ER, Relational, ODL data models are all based on schema Structure of data is rigid and known is advance.
Normal Forms Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems June 18, 2016 Some slide content courtesy of Susan Davidson.
XML: Extensible Markup Language
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Schema Refinement and Normalization
Schema Refinement and Normalization
Normal Forms and XML Zachary G. Ives October 10, 2007
XML and Non-Relational Schemas
Schema Normalization & XML
Presentation transcript:

Normal Forms, XML, and Schemas Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 13, 2005 Some slide content courtesy of Susan Davidson & Raghu Ramakrishnan

2 Announcements  Homework 3 due noon  We will post a solution set shortly afterwards  (No late turn-ins!)  Midterm: Thursday 10/20  Project groups (and optionally proposals) due 10/20  We are aiming for a recitation section for the RSS project around 10/24-10/26

3 Two Important Normal Forms Boyce-Codd Normal Form (BCNF). For every relation scheme R and for every X  A that holds over R, either A  X (it is trivial),or or X is a superkey for R Third Normal Form (3NF). For every relation scheme R and for every X  A that holds over R, either A  X (it is trivial), or X is a superkey for R, or A is a member of some key for R

4 Normal Forms Compared BCNF is preferable, but sometimes in conflict with the goal of dependency preservation  It’s strictly stronger than 3NF Let’s see algorithms to obtain:  A BCNF lossless join decomposition (nondeterministic)  A 3NF lossless join, dependency preserving decomposition

5 BCNF Decomposition Algorithm (from Korth et al.; our book gives a recursive version) result := {R} compute F+ while there is a relation schema R i in result that isn’t in BCNF { let A  B be a nontrivial FD on R i s.t. A  R i is not in F+ and A and B are disjoint result:= (result – R i )  {(R i - B), (A,B)} } i.e., A doesn’t form a key

6 An Example Given the schema: Stuff(sid, name, serno, classroom, cid, fid, prof) And FDs: sid  nameserno  classroom, cid, fid fid  prof  Find the Boyce-Codd Normal Form for this schema  What if instead: sid  name classroom, cid  serno fid  prof serno  cid

7 3NF Decomposition Algorithm Let F be a minimal cover i:=0 for each FD A  B in F { if none of the schemas R j, 1  j  i, contains AB { increment i R i := (A, B) } if no schema R j, 1  j  i contains a candidate key for R { increment i R i := any candidate key for R } return (R 1, …, R i ) Build dep.- preserving decomp. Ensure lossless decomp.

8 An Example Given the schema: Stuff(sid, name, serno, classroom, cid, fid, prof) And FDs: sid  nameserno  classroom, cid, fid fid  prof  Find the Third Normal Form for this schema  What if instead: sid  name classroom, cid  serno fid  prof serno  cid

9 Summary of Normalization  We can always decompose into 3NF and get:  Lossless join  Dependency preservation  But with BCNF:  We are only guaranteed lossless joins  The algorithm is nondeterministic, so there is not a unique decomposition for a given schema R  BCNF is stronger than 3NF: every BCNF schema is also in 3NF

10 Normalization Is Good… Or Is It?  In some cases, we might not mind redundancy, if the data isn’t directly updated:  Reports (people like to see breakdowns by semester, department, course, etc.)  Warehouses (archived copies of data for doing complex analysis)  Data sharing (sometimes we may export data into object- oriented or hierarchical formats)

11 XML: A Semi-Structured Data Model

12 Why XML? XML is the confluence of several factors:  The Web needed a more declarative format for data  Documents needed a mechanism for extended tags  Database people needed a more flexible interchange format  “Lingua franca” of data  It’s parsable even if we don’t know what it means! Original expectation:  The whole web would go to XML instead of HTML Today’s reality:  Not so… But XML is used all over “under the covers”

13 Why DB People Like XML Can get data from all sorts of sources  Allows us to touch data we don’t own!  This was actually a huge change in the DB community Interesting relationships with DB techniques  Useful to do relational-style operations  Leverages ideas from object-oriented, semistructured data Blends schema and data into one format  Unlike relational model, where we need schema first  … But too little schema can be a drawback, too!

14 XML Anatomy Kurt P. Brown PRPL: A Database Workload Specification Language 1992 Univ. of Wisconsin-Madison Paul R. McJones The 1995 SQL Reunion Digital System Research Center Report SRC db/labs/dec/SRC html Processing Instr. Element Attribute Close-tag Open-tag

15 Well-Formed XML A legal XML document – fully parsable by an XML parser  All open-tags have matching close-tags (unlike so many HTML documents!), or a special: shortcut for empty tags (equivalent to  Attributes (which are unordered, in contrast to elements) only appear once in an element  There’s a single root element  XML is case-sensitive

16 XML as a Data Model XML “information set” includes 7 types of nodes:  Document (root)  Element  Attribute  Processing instruction  Text (content)  Namespace  Comment XML data model includes this, plus typing info, plus order info and a few other things

17 XML Data Model Visualized (and simplified!) Root ?xml dblp mastersthesis article mdate key authortitleyearschool editortitleyearjournalvolumeee mdate key 2002… ms/Brown92 Kurt P…. PRPL… 1992 Univ…. 2002… tr/dec/… Paul R. The… Digital… SRC… 1997 db/labs/dec attribute root p-i element text

18 What Does XML Do?  Serves as a document format (super-HTML)  Allows custom tags (e.g., used by MS Word, openoffice)  Supplement it with stylesheets (XSL) to define formatting  Data exchange format (must agree on terminology)  Marshalling and unmarshalling data in SOAP and Web Services

19 XML as a Super-HTML (MS Word) CIS 550: Database and Information Systems Fall Towne, Tuesday/Thursday 1:30PM – 3:00PM

20 XML Easily Encodes Relations sidsernoexp-grade B A B A Student-course-grade

21 But XML is More Flexible… “Non-First-Normal-Form” (NF 2 ) John Joan Jill Felicity … Coincides with “semi-structured data”, invented by DB people at Penn and Stanford

22 XML and Code  Web Services (.NET, recent Java web service toolkits) are using XML to pass parameters and make function calls  Why?  Easy to be forwards-compatible  Easy to read over and validate (?)  Generally firewall-compatible  Drawbacks? XML is a verbose and inefficient encoding!  XML is used to represent:  SOAP: the “envelope” that data is marshalled into  XML Schema: gives some typing info about structures being passed  WSDL: the IDL (interface def language)  UDDI: provides an interface for querying about web services

23 Integrating XML: What If We Have Multiple Sources with the Same Tags?  Namespaces allow us to specify a context for different tags  Two parts:  Binding of namespace to URI  Qualified names is in the default namespace (aspace) is in myns is a different tag in otherns

24 XML Isn’t Enough on Its Own It’s too unconstrained for many cases!  How will we know when we’re getting garbage?  How will we query?  How will we understand what we got? We also need: Some idea of the structure  Our focus next Presentation, in some cases – XSL(T)  We’ll talk about this soon Some way of interpreting the tags…?  We’ll talk about this later in the semester

25 Structural Constraints: Document Type Definitions (DTDs) The DTD is an EBNF grammar defining XML structure  XML document specifies an associated DTD, plus the root element  DTD specifies children of the root (and so on) DTD defines special significance for attributes:  IDs – special attributes that are analogous to keys for elements  IDREFs – references to IDs  IDREFS – a nasty hack that represents a list of IDREFs

26 An Example DTD Example DTD: <!ATTLIST mastersthesis(mdateCDATA#REQUIRED keyID#REQUIRED advisorCDATA#IMPLIED> … Example use of DTD in XML file: …

27 Representing Graphs and Links in XML John Smith Paper1 Paper2 …

28 Graph Data Model Root !DOCTYPE graph author article name title ref John Smith author1 Paper2 ?xml article id author1 author title Paper1

29 Graph Data Model Root !DOCTYPE graph author article name title ref John Smith Paper2 ?xml article id author1 author title Paper1

30 DTDs Aren’t Expressive Enough DTDs capture grammatical structure, but have some drawbacks:  Not themselves in XML – inconvenient to build tools for them  Don’t capture database datatypes’ domains  IDs aren’t a good implementation of keys  Why not?  No way of defining OO-like inheritance

31 XML Schema Aims to address the shortcomings of DTDs  XML syntax  Can define keys using XPaths  Type subclassing that’s more complex than in a programming language  Programming languages don’t consider order of member variables!  Subclassing “by extension” and “by restriction”  … And, of course, domains and built-in datatypes

32 Basics of XML Schema Need to use the XML Schema namespace (generally named xsd)  simpleTypes are a way of restricting domains on scalars  Can define a simpleType based on integer, with values within a particular range  complexTypes are a way of defining element/attribute structures  Basically equivalent to !ELEMENT, but more powerful  Specify sequence, choice between child elements  Specify minOccurs and maxOccurs (default 1)  Must associate an element/attribute with a simpleType, or an element with a complexType

33 Simple Schema Example

34 Designing an XML Schema/DTD Not as formalized as relational data design  We can still use ER diagrams to break into entity, relationship sets  ER diagrams have extensions for “aggregation” – treating smaller diagrams as entities – and for composite attributes  Note that often we already have our data in relations and need to design the XML schema to export them! Generally orient the XML tree around the “central” objects Big decision: element vs. attribute  Element if it has its own properties, or if you *might* have more than one of them  Attribute if it is a single property – or perhaps not!