VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Identity Constraints.

Slides:



Advertisements
Similar presentations
XML: Extensible Markup Language
Advertisements

1 DTD (Document Type Definition) Imposing Structure on XML Documents (W3Schools on DTDs)W3Schools on DTDs.
Data Modeling using XML Schemas Murali Mani Extreme 2002.
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.
An Introduction to XML Schema CSCI 7818 by Ming Rutar.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
Introduction to Structured Query Language (SQL)
XML Schemas Lecture 10, 07/10/02. Acknowledgements A great portion of this presentation has been borrowed from Roger Costello’s excellent presentation.
XML Schema Matthias Hauswirth. Agenda 4 W3C Process 4 XML Schema Requirements 4 The Specifications 4 Schema Tools.
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
1 Modelling Hachim Haddouti Al Akhawayn University SSE
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.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Read Lecturer.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Write Lecturer.
4/20/2017.
Processing of structured documents Spring 2003, Part 3 Helena Ahonen-Myka.
XML – Data Model, DTD and Schema
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Document Type Definition.
SDPL 2002Notes 2: Document Instances and Grammars1 2.5 XML Schemas n A quick introduction to XML Schema –W3C Recommendation, May 2, 2001: »XML Schema Part.
Lecture 21 XML querying. 2 XSL (eXtensible Stylesheet Language) In HTML, default styling is built into browsers as tag set for HTML is predefined and.
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.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XQuery.
An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XQuery.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Storage Techniques.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
XML Schema and Stylus Studio. Introduction to XML Schema XML Schema defines building blocks of a XML document XML Schemas are alternative to DTD Why XML.
1 Introduction to XML Schemas using eXcelon Stylus Studio XML schema language is a standard for specifying the structure of XML documents Uses the same.
A Z Approach in Validating ORA-SS Data Models Scott Uk-Jin Lee Jing Sun Gillian Dobbie Yuan Fang Li.
XML Structures For Existing Databases Ref: 106.ibm.com/developerworks/xml/library/x-struct/
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation eXist Update Lecturer.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Schema 2 Lecturer.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Aggregation.
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 –
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.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Query Data Model Lecturer.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XML.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Exam and Lecture Overview.
XML Schema. Why Schema? To define a class of XML documents Serve same purpose as DTD “Instance document" used for XML document conforming to schema.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Architecture.
Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.
XP New Perspectives on XML, 2 nd Edition Tutorial 8 1 TUTORIAL 8 CREATING ELEMENT GROUPS.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Mapping RDB Schema to.
Management of XML and Semistructured Data Lecture 10: Schemas Monday, April 30, 2001.
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
Introduction to XML Schema John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: (x2073)
Session 1 Module 1: Introduction to Data Integrity
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)
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.
Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 14 This presentation © 2004, MacAvon Media Productions XML.
CITA 330 Section 4 XML Schema. XML Schema (XSD) An alternative industry standard for defining XML dialects More expressive than DTD Using XML syntax Promoting.
4 Copyright © 2004, Oracle. All rights reserved. Validating XML by Using XML Schema.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
Lecture # 14 Chapter # 5 The Relational Data Model and Relational Database Constraints Database Systems.
CITA 330 Section 2 DTD. Defining XML Dialects “Well-formedness” is the minimal requirement for an XML document; all XML parsers can check it Any useful.
Modified Slides from Dr.Peter Buneman 1 XML Constraints Constraints are a fundamental part of the semantics of the data; XML may not come with a DTD/type.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
MSc in Communication Sciences Program in Technologies for Human Communication Davide Eynard Facoltà di scienze della comunicazione Università.
XML: Extensible Markup Language
Database Constraints Ashima Wadhwa.
Lecturer : Dr. Pavle Mogin
2/18/2019.
XML Constraints Constraints are a fundamental part of the semantics of the data; XML may not come with a DTD/type – thus constraints are often the only.
Presentation transcript:

VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation Identity Constraints Lecturer : Dr. Pavle Mogin

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 1 Plan for XML Identity Constraints Defining XML Schema identity constraints: –Unique, –Key, –Key reference The syntax of XML Schema constraints The role of relative location path in defining constraints –Reading: XML Schema Part 0: Primer (W3C Recommendation, 2 May 2001) XML Schema Part 1: Structures

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 2 schoolReport.xml (1 of 2) <student id=“007” inTerm=“34.75”/> <student id=“131” inTerm=“30.75”/> <student id=“007” inTerm=“29.50”/> <student id=“505” inTerm=“33.00”/>

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 3 schoolReport.xml (2 of 2) James Bond James Smith Emmy Smith

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 4 student Partial Tree of schoolReport.xml d1d1 SchoolReport.xml e1e1 SchoolReport class students comp302 name classes id inTerm a1a1 e2e2 a2a2 e4e4 a3a3 007 student idinTerm e3e3 student class id inTerm student id inTerm 505 comp442 name a4a4 a4a4 a6a6 a5a5 e5e5 e6e6 e7e7 a7a e8e8 a8a8 a9a9 e 13

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 5 students e 13 Subtree students student 007 id James 131 id Emmy 505 id e 13 e 14 a7a7 a8a8 a9a9 e 15 name Bond surname t5t5 t6t6 Smith surname e 16 e 17 e 18 e 19 t7t7 t8t8 e 20 e 21 Smith surname e 22 t9t9 t 10

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 6 The School Report Schema <xsd:schema xmlns:xsd=“ School Report Schema

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 7 schoolReport Element <xsd:element name=“classes” type=“ClassesType”/> <xsd:element name=“students” type=“StudentsType”/>

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 8 key and keyref Declarations

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 9 Classes Type <xsd:element name=“student” maxOccurs=“unbounded”> <xsd:attribute name=“inTerm” type=“xsd:decimal”/>

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 10 Students Type <xsd:element name=“name” type=“xsd:string”> <xsd:element name=“surname” type=“xsd:string”>

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 11 Identity Constraints(1) An identity constraint is defined using elements: –unique | key | keyref (to declare the type (kind) of the constraint and to name it), –selector (to define the scope of the constraint), and –field (to designate a simple concept whose values have to be checked) A field can be either an element having simple type values, or an attribute If the constraint type is unique or keyref, field value can be declared to be optional or nilable Syntax: The xsd:keyref also has the attribute refer

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 12 Identity Constraints(2) XML Schema enables us to define: –A unique constraint, –A key constraint, and –A referential integrity constraint These three constraints apply to a certain part of a document only and their satisfaction is checked by an XML Schema processor The three important concepts: –The context node of the constraint, –The scope of the constraint, and –The argument of the constraint

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 13 Identity Constraints(3) The context node of a constraint is an element from which there is a downward path to the scope of the constraint The scope of a constraint defines a sequence of element instances within which the constraint has to be valid –A scope element is most often complex and multivalued –It is defined using a relative location path expression starting from the context node The argument of a constraint is a simple concept (a simple element or attribute) whose values have to obey to rules of the constraint within the scope: –To be unique and not null (key constraint), –To be unique (unique constraint), or –To reference an existing value of a key constraint

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 14 Location Path Example Consider the schoolReport.xml document, and suppose we want to values of each student to be unique and not null within students subtree Let schoolReport (e 1 ) be the context node The relative location path expression (called selector xpath ) students/student defines the scope and returns (e 14, e 17, e 20 ) The path (relative to the previously defined defines the argument (called field ) and returns (a 7, a 8, a 9 ) whose values have to be unique and not null

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 15 Where to Declare an Identity Constraint Identity constraints are declared within the content of an element in an XML Schema schema How to decide on this element –The identity constraint has to be valid in a sequence of document concepts (scope of the constraint), –The element from which there is a downward path to the element whose instances make the scope sequence, should be selected as the context node of the identity constraint, –The selector path leads from the context to the scope element, –The field path returns at most one single valued concept for each element instance in the sequence returned by the selector path

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 16 Simple Unique Constraint (Attribute) Suppose the next declaration is specified within the declaration of the classes element of the schoolReport.xsd Then value of each class in the classes have to be unique The context node of the xsd:selector ’s xpath is classes The sequence of context nodes of the xsd:field ’s xpath are class nodes (e 3, e 6 ) So, xsd:field ‘s xpath specifies that there should be a unique value of attribute associated with each class element in (e 3, e 6 ) (this also implies (a 1, a 4 ) should be unique)

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 17 Composite Unique Constraint (Element) Consider the schoolReport.xml and suppose the next declaration is specified within the content model of the students element Then the string values of each combination of name and surname elements in the students/student have to be unique The context node of the xsd:selector ’s xpath is students (e 13 ) The context nodes of the xsd:field ’s xpath are student nodes (e 14, e 17, e 20 )

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 18 Defining Keys & Their References The syntax for the key constraint is very similar to the syntax for defining the unique constraint The key declaration on a field means that (within the scope specified) field values: –Must be unique, and –Cannot be set to nil, or omitted A key enables defining a referential integrity constraint within the given scope

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 19 Key and Referential Integrity Example To insure that each student id in classes/class belongs to a real student in students, a key is defined within the declaration of the schoolReport element and it is referenced by that is also defined within the schoolReport element

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 20 Placement of key and keyref Constraints The key constraint has to be “visible” to the keyref constraint –i.e. there has to exist a non upwards path from the keyref definition to the key definition That means we can place –Both key and keyref within the schoolReport element, or –The key constraint within the students element and keyref within the schoolReport element But we can’t place: –The key constraint within the schoolReport element and the keyref constraint within the classes element, or –The key constraint within the students element and keyref within the classes element

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 21 Schema Versus DTD Constraints (1) XML 1.0 provides mechanisms: –For ensuring uniqueness using an attribute of the ID type and –References using attributes of the IDREF(S) type The ID/IDREF(S) types are applicable on attributes only and the scope of the ID constraint is a whole document Each ID value has to be unique across a whole document Additionally, ID attributes have to be single valued, composite uniqueness constraint can not be defined

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 22 Schema Versus DTD Constraints (2) The XML Schema supports ID and IDREF(S) types for compatibility reasons Contrary to ID/IDREF types, a field of XML Schema unique, keyref and key constraints can be either an element, or an attribute, their type can be any XML Schema basic type, and their scope can be precisely defined using XPath expressions Further, using multiple field elements, one can define a composite identity constraint

SWEN 432 Advanced Database Design and Implementation 2015 Identity Constraints 23 Summary XML Schema supports defining: –unique, –key, and –keyref constraints All three constraints have a very similar syntax containing two relative location path expressions: –The first one defines the hierarchical path to a non empty multivalued complex element that represents the scope –The second one defines either a descendant element having simple values, or an attribute (both are called “ field ”) of the selected complex element whose values have to be constrained