COMP3381 Software, Systems and Applications III
Lecturer: Prof. Alexandra I. Cristea Assessment: summative
Hand-in method: DUO
Document format: PDF
Advanced Databases:
Consider the following two XML documents, books.xml and media.xml. students.xml
XML and XQuery
teachers.xml
The assignment is divided into two parts (Part A, Part B), as it is shown below. Details for marking are in the Marking Scheme below.
Part A.
a. Draw the directed tree structure of the students.xml XML file (i.e. the Hierarchical Tree Model). Please ensure that you include in your tree all the necessary labels. Hint: If you have not enough space, you can write the names of the nodes next to the nodes (instead of inside the nodes), and use a star-like display.
b. Write a DTD for the teachers.xml XML file above. Use a validator to ensure the correctness of your DTD and explain which one you used. Hint: You may need to search the web for some parts of the answer.
c. Is it possible to write a DTD for the students.xml XML file above? Explain which construct would be problematic. How could this be done in XML for correct validation? Hint: You may need to search the web for some parts of the answer.
Part B.
Assume that the above XML code is stored in their respective files, students.xml and teachers.xml. Based on these XML files, write the following queries as required below.
Write
a. b.
Write c. d.
e.
an XPath query for each of the following:
Find all students who study ¡®Advanced Databases¡¯ this year.
Find all teachers who teach ¡®Advanced Databases¡¯ this year. an XQuery query for each of the following:
How many years has Professor Cristea been teaching ¡®Advanced Databases¡¯ (at Durham)?
Find all students in year 3 currently taught by Alexandra.
How many teachers and how many students are kept in the databases where the last name is not known?
Additionally, for each query a.-e. above you must:
(i) Explain how you interpreted the (natural language) query, and thus why your answer
is appropriate.
(ii) Explain also limitations of your approach, if there are any.
(iii) Please provide also the output of these queries, when applying them to the two XML
files above.
Furthermore, for each query c.-e. above, additionally to (i)-(iii) above, you must:
(iv) Comment if the XQuery query could be answered with an XPath query, and give the XPath query if that is the case. Otherwise, explain why the query can only be written as an XQuery query.
Hints: For maximum marks in Part B, consider writing the query in such a way, that if the databases would be extended, you would still get the correct answer; consider this for (ii) above. Also consider formatting your output, where possible. Check that your interpretation for (i) is not an over-simplification.
Marking Scheme
Part Question No.
A a.
b.
c.
B a.
b.
c.
d.
e.
Detail Marks
All elements represented 5
All attributes represented 5
All values represented 5
Whole structure correct 5
All elements represented 5
All attributes represented 5
Whole structure correct 5
Explanation 2
Query 5
(i) Interpretation 2
(ii)
(iii)
(i)
(ii)
(iii)
(i)
(ii)
(iii)
(iv)
(i)
(ii)
(iii)
(iv)
(i)
(ii)
(iii)
(iv)
Limitations 3
Output 2
Query 5
Interpretation 2
Limitations 3
Output 2
Query 5
Interpretation 2
Limitations 1
Output 1
XPath+Explanation 4
Query 5
Interpretation 2
Limitations 1
Output 1
XPath+Explanation 4
Query 5
Interpretation 2
Limitations 1
Output 1
XPath+Explanation 4