Πανεπιστήµιο Κρήτης Τµήµα Επιστήµης Υπολογιστών. ΗΥ-561 ιαχείριση εδοµένων στο Παγκόσµιο Ιστό Βασίλης Χριστοφίδης

Σχετικά έγγραφα
EE512: Error Control Coding

Fractional Colorings and Zykov Products of graphs

Example Sheet 3 Solutions

2 Composition. Invertible Mappings

5. Επερώτηση XML Εγγράφων: Εισαγωγή στη Γλώσσα XQuery

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Every set of first-order formulas is equivalent to an independent set

derivation of the Laplacian from rectangular to spherical coordinates

C.S. 430 Assignment 6, Sample Solutions

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible.

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

5. Choice under Uncertainty

Nowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

Practice Exam 2. Conceptual Questions. 1. State a Basic identity and then verify it. (a) Identity: Solution: One identity is csc(θ) = 1

Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016

The Simply Typed Lambda Calculus

SCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions

Approximation of distance between locations on earth given by latitude and longitude

Inverse trigonometric functions & General Solution of Trigonometric Equations

Αλγόριθμοι και πολυπλοκότητα NP-Completeness (2)

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής

The challenges of non-stable predicates

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ. ΕΠΛ342: Βάσεις Δεδομένων. Χειμερινό Εξάμηνο Φροντιστήριο 10 ΛΥΣΕΙΣ. Επερωτήσεις SQL

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

Section 8.3 Trigonometric Equations

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

Instruction Execution Times

CRASH COURSE IN PRECALCULUS

Jesse Maassen and Mark Lundstrom Purdue University November 25, 2013

Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3

A Note on Intuitionistic Fuzzy. Equivalence Relation

Finite Field Problems: Solutions

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

Other Test Constructions: Likelihood Ratio & Bayes Tests

Partial Trace and Partial Transpose

Matrices and Determinants

A Lambda Model Characterizing Computational Behaviours of Terms

k A = [k, k]( )[a 1, a 2 ] = [ka 1,ka 2 ] 4For the division of two intervals of confidence in R +

PARTIAL NOTES for 6.1 Trigonometric Identities

Concrete Mathematics Exercises from 30 September 2016

ST5224: Advanced Statistical Theory II

About these lecture notes. Simply Typed λ-calculus. Types

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

Uniform Convergence of Fourier Series Michael Taylor

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

Lecture 2. Soundness and completeness of propositional logic

Partial Differential Equations in Biology The boundary element method. March 26, 2013

Second Order Partial Differential Equations

Reminders: linear functions

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =?

Μοντέλο. για ημι-δομημένα μημ δεδομένα. Ημι-δομημένα δεδομένα XML DTD XML Schema

Second Order RLC Filters

Chapter 6: Systems of Linear Differential. be continuous functions on the interval

SOAP API. Table of Contents

Εισαγωγή(στη(γλώσσα(XML(

Cyclic or elementary abelian Covers of K 4

Απόκριση σε Μοναδιαία Ωστική Δύναμη (Unit Impulse) Απόκριση σε Δυνάμεις Αυθαίρετα Μεταβαλλόμενες με το Χρόνο. Απόστολος Σ.

Πανεπιστήμιο Κρήτης Τμήμα Επιστήμης Υπολογιστών. ΗΥ-561 Διαχείριση Δεδομένων στο Παγκόσμιο Ιστό Βασίλης Χριστοφίδης

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

Math 6 SL Probability Distributions Practice Test Mark Scheme

4.6 Autoregressive Moving Average Model ARMA(1,1)

Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1

5.4 The Poisson Distribution.

TMA4115 Matematikk 3

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

Συστήματα Διαχείρισης Βάσεων Δεδομένων

Srednicki Chapter 55

Homework 3 Solutions

LTL to Buchi. Overview. Buchi Model Checking LTL Translating LTL into Buchi. Ralf Huuck. Buchi Automata. Example

Homework 8 Model Solution Section

department listing department name αχχουντσ ϕανε βαλικτ δδσϕηασδδη σδηφγ ασκϕηλκ τεχηνιχαλ αλαν ϕουν διξ τεχηνιχαλ ϕοην µαριανι

Commutative Monoids in Intuitionistic Fuzzy Sets

Τα web services του παρατηρητηρίου τιμών ακολουθούν λογική REST και απαντούν σε GET requests ως ακολούθως:

Solutions to the Schrodinger equation atomic orbitals. Ψ 1 s Ψ 2 s Ψ 2 px Ψ 2 py Ψ 2 pz

Problem Set 3: Solutions

Section 7.6 Double and Half Angle Formulas

SCITECH Volume 13, Issue 2 RESEARCH ORGANISATION Published online: March 29, 2018

Solutions to Exercise Sheet 5

Math221: HW# 1 solutions

ΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ

Homomorphism in Intuitionistic Fuzzy Automata

6.3 Forecasting ARMA processes

ΠΑΝΕΠΙΣΤΗΜΙΟ ΠΕΙΡΑΙΩΣ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ. Βάσεις Δεδομένων (4 ο εξάμηνο) Εργαστήριο MySQL #2

ΗΥ-360 Αρχεία και Βάσεις Δεδομένων Διδάσκων: Δ. Πλεξουσάκης. Φροντιστήριο SQL Examples ΙΙ Ξένου Ρουμπίνη

Πληροφοριακά Συστήµατα

Generating Set of the Complete Semigroups of Binary Relations

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Quadratic Expressions

D Alembert s Solution to the Wave Equation

Assalamu `alaikum wr. wb.

Sequent Calculi for the Modal µ-calculus over S5. Luca Alberucci, University of Berne. Logic Colloquium Berne, July 4th 2008

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 5: Component Adaptation Environment (COPE)

w o = R 1 p. (1) R = p =. = 1

(C) 2010 Pearson Education, Inc. All rights reserved.

«Χρήσεις γης, αξίες γης και κυκλοφοριακές ρυθμίσεις στο Δήμο Χαλκιδέων. Η μεταξύ τους σχέση και εξέλιξη.»

Transcript:

Πανεπιστήµιο Κρήτης Τµήµα Επιστήµης Υπολογιστών ΗΥ-561 ιαχείριση εδοµένων στο Παγκόσµιο Ιστό Βασίλης Χριστοφίδης Ονοµατεπώνυµο: Αριθµός Μητρώου: Άσκηση 1 (55 µονάδες) Τελική Εξέταση (3 ώρες) Ηµεροµηνία: Τρίτη 28 Ιουνίου 2005 Σας δίνεται το παρακάτω µοντέλο οντοτήτων-συσχετίσεων (ΟΣ) για την αναπαράσταση πληροφορίας σχετικής µε την εξυπηρέτηση πελατών από διαφορετικές εταιρίες κινητής τηλεφωνίας. Area Code Phone No. State Zip Phone Email Year of Birth City Address Customer Name Street Name SSN Street No. Uses Service Provider Name Service Plan Plan Id Plan Title Monthly fee Anytime minute Night weekend minute 1.(15 µονάδες) Μεταφράστε το παραπάνω µοντέλο ΟΣ σε σχήµα XML. Σχεδιάστε κατάλληλους τύπους στοιχείων XML για κάθε οντότητα λαµβάνοντας υπόψη τους περιορισµούς ακεραιότητας (κλειδιά, εξωτερικά κλειδιά) καθώς και ότι: Α) Για κάθε Πελάτη (Customer): SSN (1 occurrence, required) Name (1 occurrence, required) Year of Birth (CCYY-MM-DD) (0 or 1 occurrence, optional)

Phone (1 occurrence, required) Address (0 or 1 occurrence, optional) Email (0 or more occurrences, optional) Plan Id (1 occurrence, required) Β) Για κάθε προσφερόµενη Υπηρεσία (Service Plan): Plan Id (1 occurrence, required) Plan Title (1 occurrence, required) Service Provider Name (1 occurrence, required) Monthly fee (values from 10 to 115, required) Anytime minute (1 occurrence, required) Night & weekend minute (0 or 1 occurrence, optional) Για λόγους ευκολίας, υποθέστε ότι κάθε πελάτης έχει µόνο ένα κινητό τηλέφωνο. <?xml version="1.0" encoding="utf-8"?> <xs:schema elementformdefault="qualified" xmlns:xs="http://www.w3.org/2001/xmlschema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xs:nonamespaceschemalocation="plans.xsd"> <xs:element name="customers"> <xs:element ref="customer" minoccurs="0" maxoccurs="unbounded" /> <xs:element name="customer"> <xs:element name="ssn" type="xs:string" <xs:key name="customerskey"> <xs:selector xpath=".//customer" /> <xs:field xpath="ssn" /> </xs:key> <xs:element name="name" type="xs:string" <xs:element name="year_of_birth" type="rsh_date" minoccurs="0" maxoccurs="1" nillable="true"/> <xs:element ref="phone" <xs:element ref="address" minoccurs="0" maxoccurs="1" nillable="true"/> <xs:element name="email" type="xs:string" minoccurs="0" maxoccurs="unbounded" nillable="true"/> <xs:element name="plan_id" type="xs:int"> <xs:keyref name="uses" msdata:refrencekey="true" refer="service_planskey"> <xs:selector xpath=".//customer" /> <xs:field xpath="plan_id" /> </xs:keyref> <xs:simpletype name="rsh_date"> <xs:restriction base="xs:string"> <xs:pattern value="\d{4-\d{2-\d{2" /> <!-- Normal date --> <xs:pattern value="\d{4-\d{1-\d{2" /> <xs:pattern value="\d{4-\d{2-\d{1" /> <xs:pattern value="\d{4-\d{1-\d{1" />

</xs:restriction> </xs:simpletype> <xs:element name="phone"> <xs:element name="area_code" type="xs:string" /> <xs:element name="phone_no" type="xs:string" /> <xs:element name="address"> <xs:element name="street_no" type="xs:string" /> <xs:element name="street_name" type="xs:string" /> <xs:element name="city" type="xs:string" /> <xs:element name="state" type="xs:string" /> <xs:element name="zip" type="xs:string" /> </xs:schema> <?xml version="1.0" encoding="utf-8"?> <xs:schema elementformdefault="qualified" xmlns:xs="http://www.w3.org/2001/xmlschema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="serviceplans"> <xs:element ref="service_plan" minoccurs="0" maxoccurs="unbounded" /> <xs:element name="service_plan"> <xs:element name="plan_id" type="xs:int" <xs:key name="service_planskey" msdata:primarykey="true"> <xs:selector xpath=".//service_plan" /> <xs:field xpath="plan_id" /> </xs:key> <xs:element name="plan_title" type="xs:string" <xs:element name="service_provider_name" type="xs:string" <xs:element name="monthly_fee" type="fee_type" <xs:element name="anytime_minute" type="xs:int" <xs:element name="night_and_weekend_minutes" type="xs:nonnegativeinteger" minoccurs="0" maxoccurs="1"/> <xs:simpletype name="fee_type"> <xs:restriction base="xs:unsignedbyte"> <xs:mininclusive value="10" /> <xs:maxinclusive value="115" /> </xs:restriction> </xs:simpletype> </xs:schema>

2.(25 µονάδες) ώστε τις εκφράσεις XQuery καθώς και τον τύπο του αποτελέσµατος τους για τις παρακάτω επερωτήσεις, υποθέτοντας ότι σας δίνονται δύο σχετικά έγγραφα XML customers.xml και plans.xml: a) ώστε τις διευθύνσεις ηλεκτρονικού ταχυδροµείου για κάθε πελάτη. (Κάθε διεύθυνση ηλεκτρονικού ταχυδροµείου πρέπει να διαχωρίζεται από ","). Ταξινοµήστε το αποτέλεσµα σε αύξουσα σειρά ως προς το όνοµα των πελατών. for $customer in document("customers.xml")//customer order by $customer/name ascending return <email_info> { $customer/name, <emails> {for $em in $customer/email return ($em/text(), ", ") </emails> </email_info> element email_info { element Name {xsd:string, element emails {{text* * b) ώστε τον αριθµό πελατών για κάθε ταχυδροµικό κώδικα (zip). Ταξινοµήστε το αποτέλεσµα σε φθίνουσα σειρά ως προς τον αριθµό των πελατών. for $zip in (distinct-values(document("customers.xml")//zip)) let $customer_num := count(document("customers.xml")//customer [Address/Zip = $zip]) order by $customer_num descending return <customer_num> { $zip, if ($customer_num < 10) then <count>0{$customer_num</count> else <count>{$customer_num</count> </customer_num> element customer_num { element Zip {xsd:string, element count {xsd:integer * c) ώστε τη µέση µηνιαία χρέωση σύνδεσης για κάθε εταιρία παροχής κινητής τηλεφωνίας. (Η συνάρτηση avg της XQuery δέχεται ως είσοδο µια ακολουθία τιµών µε τύπο xdt:anyatomictype οι οποίες στην συνέχεια µετατρέπονται σε double για να τις χειριστεί η συνάρτηση. Τελικά ο επιστρεφόµενος τύπος είναι xdt:anyatomictype.)

for $sp in distinct-values(document("plans.xml") //Service_Provider_Name) let $monthly_fee := document("plans.xml")//service_plan [Service_Provider_Name = $sp]/monthly_fee return <Avg_Monthly_Fee> { $sp, <Average_Monthly_Fee>{avg($monthly_fee)</Average_Monthly_Fee> </Avg_Monthly_Fee> element Avg_Monthly_Fee { element Service_Provider_Name {xsd:string, element Average_monthly_Fee {xdt:anyatomictype * d) ώστε τον αριθµό πελατών για κάθε εταιρία παροχής κινητής τηλεφωνίας. Ταξινοµήστε το αποτέλεσµα σε φθίνουσα σειρά ως προς τον αριθµό των πελατών. let $sp := document("plans.xml")//service_plan for $spn in distinct-values($sp/service_provider_name) let $customer_num := count(document("customers.xml")//customer [Plan_ID = $sp[service_provider_name = $spn]/plan_id]/ssn) order by $customer_num descending return <Num_Customers> { $spn, if ($customer_num < 10) then <count>0{$customer_num</count> else <count>{$customer_num</count> </Num_Customers> element Num_Customers { element Service_Provider_Name {xsd:string, element count {xsd:integer * e) ώστε το όνοµα των πελατών που έχουν την υπηρεσία χαµηλής χρέωσης την νύχτα και τα Σαββατοκύριακα (Night and weekend minute service). for $customer in document("customers.xml")//customer, $sp in document("plans.xml")//service_plan where $sp/plan_id = $customer/plan_id and not(empty($sp/night_and_weekend_minutes)) return $customer/name element Name {xsd:string* 3. (15 µονάδες) Καθορίστε τη σχέση εγκλεισµού (περιέχει, περιέχεται, ισοδύναµη, ή κανένα από τα ανωτέρω) µεταξύ των παρακάτω XPath εκφράσεων E και E': 1. E = /a/b[.//a/b], E' = //a/b 2. E = /a[.//b[c/d]]/b/c/d, E' = /a/b/c/d 3. E = /a[b > 0]/c, E' = /a[b > 10]/c ικαιολογήστε σύντοµα την απάντησή σας.

1. E' contains E (i.e., The answers for the query E' is ALWAYS a superset of the results for E) 2. E' = E 3. E contains E' Άσκηση 2 (20 µονάδες) 1.(10 µονάδες) Είναι οι ακόλουθοι δύο γράφοι bisimilar; ικαιολογήστε σύντοµα την απάντησή σας. Για ευκολία υποθέστε ότι όλες οι ακµές έχουν την ίδια ετικέτα "L". X X Z W Y Y Z 17 17 Claim: These graphs are bisimilar. Proof: Let G1 and G2 be the graphs above, and let R be the following relation over the nodes of G1 and G2 (described as a set of pairs): (X, X ), (Y, Y ), (Z, Z ), (W, Z ) It is easy to check that the following three statements are true: (a) R is maximal (all nodes of G1 and G2 are involved in R) (b) For each pair (t,s) in R, and for each edge (t,a,t ) in G1, there exists an edge (s,a,s ) in G2 such that (t,s ) is in R (c) [reverse of (b)] For each pair (t,s) in R, and for each edge (s,a,s ) in G2, there exists an edge (t,a,t ) in G1 such that (t,s ) is in R. Therefore R is a desired relation that establishes bisimilarity of G1 and G2. 2.(5 µονάδες) Ποια είναι τα σηµαντικά κοινά χαρακτηριστικά του αντικειµενοστρεφούς µοντέλου δεδοµένων και του µοντέλου ηµι-δοµηµένων δεδοµένων που δεν υπάρχουν στο σχεσιακό µοντέλο δεδοµένων; 1) Values are not required to be atomic (like in relational model) but can be themselves sets, tuples or relations (sets of tuples) objects have identity 2) In both the complex object and semistructured data models the data can be viewed as a graph with an arbitrary structure whereas in the relational data model we have a tree of uniform structure DB is a set of relations, relation is a set of tuples, tuples have attributes that are atomic values. 3.(5 µονάδες) Ποιες είναι οι κύριες διαφορές του αντικειµενοστραφούς µοντέλου δεδοµένων και του µοντέλου ηµι-δοµηµένων δεδοµένων; Τι επιπτώσεις έχουν αυτές οι διαφορές στην αναπαράσταση και επερώτηση των δεδοµένων;

1) Unlike complex object data models, semistructured data are self-describing (the schema is described as part of data). This could complicate query formulation and optimization. 2) The complex object data model implies only an arbitrary nesting of the data. The values inserted have to conform to this nested structure. In the semistructured data model, we can cope with irregular structure. Elements may be missing, or different elements may have a different structure. Facilities like regular path expressions have to be provided in order to query uncertain or irregular structure. For example if we have defined a complex object consisting of a set of tuples with a certain tuple structure then all tuples inserted for this object are of the same structure. This is not the case in semistructured data. E.g., in a complex object data model, when we define a nested structure like Bibliography: { <Title, Authors: {<Firstname,Lastname>> then the values for all tuples <Title, Authors: {<Firstname,Lastname>> will have to fit into the same structure Title Authors First Last abc f1 l1 f2 l2 xyz f1 l1 f2 l2 with semistructured data, it is possible to define tuples of (title,author) that do not all have the same structure. Άσκηση 3 (25 µονάδες) α) (5 µονάδες) ώστε τις βασικές διαφορές ενός µπλοκ For-Let-Where- Return (FLWR) της ΧQuery µε το αντίστοιχο µπλοκ Select-From-Where (SFW) της SQL. (a) Variables are bound based on path expressions (which may require new query primitives); (b) Query block output should be a collection of trees with bound variables within tags, rather than a collection of tuples; (c) FLWR filter supports variables assignment which combined with conditionals and functions make XQyery a fully programming language rather than a query language like SQL β) (10 µονάδες) Προτείνετε µια γλώσσα προγραµµατισµού XML για το βασικό µπλοκ δηλώσεων (FLWR) της ΧQuery η οποία να βασίζεται στον Κατηγορηµατικό Λογισµό (πχ. όπως ο Σχεσιακός Λογισµός Πεδίων) The variables in our language are bound to trees or sets of trees. We allow XPath expressions as primitives in the language, which we interpret as functions from trees to sets of trees, in the usual way. We also take as a primitive the document function. For simplicity, we ignore order. A query result is a set of trees. The head of the expression in our language is a template corresponding to the XQuery return clause, composed of a variable or list of variables, possibly nested inside XML tags. For example, return <answer > $t </answer > would map to { <answer > $t </answer >... The body of the expression contains quantifiers and conditions corresponding to the quantifiers and conditions in the XQuery for, let, where clauses. For example, for $p in document( dbinproc.xml")/dblp/inproceedings translates to { ( p)(p document( db-inproc.xml")/dblp/inproceedings).

γ) (10 µονάδες) ώστε ένα παράδειγµα της προτεινόµενης λογικής γλώσσας, µεταφράζοντας την ακόλουθη επερώτηση ΧQuery: for $p in document(`dblp-inproc.xml')/dblp/inproceedings, $a in $p/author let $t := $p/title where $a = `Serge Abiteboul' return $t; {t ( p,a,t) (p document( dblp-inproc.xml )/dblp/inproceedings a p/author t = p/title a = Serge Abiteboul )