1 Administrivia  HW3 deadline extended: Tuesday 10/7  Revised upcoming schedule:  Thurs. 10/2: Querying XML  Tues. 10/7: More on XML; beginning of.

Slides:



Advertisements
Similar presentations
XML: Extensible Markup Language
Advertisements

Normal Forms, XML, and Schemas Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 13, 2005 Some slide content.
Querying XML Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 6, 2003 Some slide content courtesy of Susan Davidson.
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.
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 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
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.
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
Databases 6: Normalization
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.
Department of Computer Science and Engineering, HKUST Slide 1 7. Relational Database Design.
Introduction to XML This material is based heavily on the tutorial by the same name at
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.
4/20/2017.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Database Systems Normal Forms. Decomposition Suppose we have a relation R[U] with a schema U={A 1,…,A n } – A decomposition of U is a set of schemas.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
1 XML at a neighborhood university near you Innovation 2005 September 16, 2005 Kwok-Bun Yue University of Houston-Clear Lake.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
Chapter 8: Relational Database Design First Normal Form First Normal Form Functional Dependencies Functional Dependencies Decomposition Decomposition Boyce-Codd.
Schema Refinement and Normalization. Functional Dependencies (Review) A functional dependency X  Y holds over relation schema R if, for every allowable.
CS143 Review: Normalization Theory Q: Is it a good table design? We can start with an ER diagram or with a large relation that contain a sample of the.
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.
SCUJ. Holliday - coen 1784–1 Schedule Today: u Normal Forms. u Section 3.6. Next u Relational Algebra. Read chapter 5 to page 199 After that u SQL Queries.
Indexing and Data Exchange Formats Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems October 17, 2015.
Computing & Information Sciences Kansas State University Tuesday, 27 Feb 2007CIS 560: Database System Concepts Lecture 18 of 42 Tuesday, 27 February 2007.
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.
The Semistructured-Data Model Programming Languages for XML Spring 2011 Instructor: Hassan Khosravi.
Temple University – CIS Dept. CIS331– Principles of Database Systems V. Megalooikonomou Database Design and Normalization (based on notes by Silberchatz,Korth,
Copyright, Harris Corporation & Ophir Frieder, The Process of Normalization.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
Carnegie Mellon Carnegie Mellon Univ. Dept. of Computer Science Database Applications C. Faloutsos Database design and normalization.
Lecture 23 XQuery 1.0 and XPath 2.0 Data Model. 2 Example 31.7 – User-Defined Function Function to return staff at a given branch. DEFINE FUNCTION staffAtBranch($bNo)
Ch 7: Normalization-Part 1
© 2016 A. Haeberlen, Z. Ives CIS 455/555: Internet and Web Systems 1 University of Pennsylvania XML (continued) February 10, 2016.
Database Management Systems, 3ed, R. Ramakrishnan and J. Gehrke1 Schema Refinement and Normal Forms Chapter 19.
Querying XML, Part II Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems February 5, 2008.
© D. Wong Functional Dependencies (FD)  Given: relation schema R(A1, …, An), and X and Y be subsets of (A1, … An). FD : X  Y means X functionally.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
1 Dept. of CIS, Temple Univ. CIS661 – Principles of Data Management V. Megalooikonomou Database design and normalization (based on slides by C. Faloutsos.
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.
Normalization and FUNctional Dependencies. Redundancy: root of several problems with relational schemas: –redundant storage, insert/delete/update anomalies.
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
Chapter 8: Relational Database Design
Handout 4 Functional Dependencies
Schema Refinement and Normalization
Schema Refinement and Normalization
Module 5: Overview of Normalization
Normal Forms and XML Zachary G. Ives October 10, 2007
Schema Refinement and Normalization
Schema Normalization & XML
Chapter 7a: Overview of Database Design -- Normalization
Presentation transcript:

1 Administrivia  HW3 deadline extended: Tuesday 10/7  Revised upcoming schedule:  Thurs. 10/2: Querying XML  Tues. 10/7: More on XML; beginning of views; HW4 out  Thurs. 10/9: Views + datalog, ctd.; review for midterm  Tues. 10/14: Fall Break  Thurs. 10/16: HW4 due; Midterm

2 Lossless Join Decomposition R 1, … R k is a lossless join decomposition of R w.r.t. an FD set F if for every instance r of R that satisfies F,  R 1 (r) ⋈... ⋈  R k (r) = r R 1, R 2 is a lossless join decomposition of R with respect to F iff at least one of the following dependencies is in F+: (R 1  R 2 )  R 1 – R 2 or(R 1  R 2 )  R 2 – R 1

3 Dependency Preservation Ensures we can check whether a FD X  Y is violated during DB updates, without using a join:  F Z, the projection of FD set F onto attribute set Z, is: {X  Y | X  Y  F +, X  Y  Z} i.e., it is those FDs only applicable to Z’s attributes  A decomposition R 1, …, R k is dependency preserving if F + = (F R 1 ...  F R k ) + (note we need an extra closure!) We don’t lose the ability to test the “cover” of our FDs in a single table, just because we decompose

4 Example 1 For Schema R(sid, name, serno, cid, subj, exp-grade) and FD set: sid  nameserno  cid cid  subjsid, serno  exp-grade Is R 1 (sid, name) and R 2 (serno, subj, cid, exp-grade):  A lossless decomposition?  Is it dependency-preserving? How about R1(sid, name) and R2(sid, serno, subj, cid, exp-grade)?

5 Example 2 Given schema R(name, street, city, st, zip, item, price), FD setname  street, citystreet, city  st street, city  zipname, item  price and decomposition R 1 (name, street, city, st, zip) and R 2 (name, item, price)  Is it lossless?  Is it dependency preserving? What if we replaced the first FD with name, street  city?

6 A More Disturbing Example… Given schema R(sid, fid, subj) and FD set: fid  subjsid, subj  fid Consider the decomposition R 1 (sid, fid) and R 2 (fid, subj)  Is it lossless?  Is it dependency preserving?  If it isn’t, can you think of a decomposition that is? Can you do this non-redundantly?

7 Redundancy vs. FDs Ideally, we want a design s.t. for each nontrivial dependency X  Y, X is a superkey for some relation schema in R  We just saw that this isn’t always possible in a non- redundant way… Thus we have two kinds of normal forms

8 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

9 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

10 BCNF Decomposition Algorithm (from Korth et al.; our book gives recursive version) result := {R} compute F+ while there is a schema R i in result that is not 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)} }

11 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.

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

XML: Semistructured Data Zachary G. Ives University of Pennsylvania CIS 550 – Database & Information Systems October 1, 2003 Some slide content courtesy of Susan Davidson & Raghu Ramakrishnan

14 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”

15 Why DB People Like XML  Can get data from all sorts of things  Allows us to touch data we don’t own  Interesting relationships with DB techniques  Can do relational-style operations  Leverages ideas from object-oriented and 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!

16 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

17 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  Attributes (which are unordered, in contrast to elements) only appear once in an element  There’s a single root element  XML is case-sensitive

18 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

19 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

20 What Does XML Do?  Serves as a document format that’s better than HTML  Allows custom tags (e.g., used by MS Word, openoffice)  Supplement it with stylesheets (XSL) to define formatting  Provides an exchange format for data (still need to agree on terminology)  Basis for RDF format for describing libraries and the Semantic Web (more on this later)  Format for marshalling and unmarshalling data in SOAP and Web Services

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

22 XML Encodes Relations sidsernoexp-grade B A B A Student-course-grade

23 But XML is More Flexible… “Non-First-Normal-Form” (NF 2 ) John Joan Jill Felicity …

24 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

25 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 namespace myns is the same is a different tag

26 XML Isn’t Normally Enough  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

27 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

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

29 Representing Graphs in XML John Smith Paper1 Paper2 …

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

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

32 DTDs Aren’t Enough for Some People  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  No way of expressing FDs

33 XML Schema  Aims to address the shortcomings of DTDs  … But an “everything including the kitchen sink” spec  Features:  XML syntax  Better way of defining keys using XPaths (which we’ll see next time)  Type subclassing that’s more complex than in a programming language  … And, of course, domains and built-in datatypes

34 Schema Example

35 Whither XML Schema?  Adopted by a few tools, but…  The jury is still out on this spec  Considered too big, bulky, inconsistent  Still no way of expressing FDs, and the key mechanism isn’t that elegant  Other people have defined more elegant schema languages, FD languages, and key languages (much of the work was Penn)  But it’s also at the core of the data model of the XQuery language and the other W3C specs…

36 Designing an XML Schema/DTD  XML data design is generally 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!  We generally orient the XML tree around the “central” objects in a particular application  A 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!

37 Wrap-up  XML is a non-first-normal-form representation  Can represent documents, data  Standard data exchange format  Several competing schema formats – esp., DTD and XML Schema – provide typing information  Next time: 3 languages for XML querying