[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
***Important*** Qn 2 on Hw3 changed..
Folks:
Hrishikesh pointed out that some of the queries I asked you to write on
Xquery will not work because of DTD problems
(because price is defined as pcdata, and books have prices listed both as
"65.95" and as " 65.95" (see the leading space in the later case)). So, I
did some changes to Qn 2.
1. There is a hint on how to do the comparison in Query 1
2. Query 2 is now changed to look for pairs of books published by the same
publisher
I also added an extra credit group-by version for query 2.
I am attaching the new version here. It is also available on the web.
Rao
In this question, you will use the Xquery interpreter available at
http://131.107.228.20
to try out writing queries in the Xquery language..
For each of the queries below, show the xquery query, as well as the
result you got by running it.
Query 1.(Selection/Projection) Using bib.xml
(http://www.bn.com/bib.xml) database, list the titles and authors of
all the books that cost less than 50$.
[[NOTE: since the prices of the entries are typed as PCDATA, and some
of them have leading spaces (e.g. "65.95" vs. " 65.95"), to do get
correct answer here your comparison should look like
..price < " 50.00" (notice the leading space before 5)
(extra credit: Try query 1, but list titles and the last name of the
second author. Hint: Look at the queries in "Usecase Sequence" in the
left pane).
Query 2.(Join)[**CHANGED**] List the pairs of books which are
published by the same publisher. The output should look as follows:
<same-publisher>
<title>
book1 title
</title>
<title>
book2 title
</title>
</same-publisher>
(make sure to ensure that book1 and book2 are actually different)
[[I gave up the 'same price' comparison because of the price
comparison problems listed in query 1.]]
(Extra Credit: This time, group books by the publisher. I.e. have
<grouped-by-publisher>
<publisher name="publishername">
<title> booktitle </title>
<title> booktitle </title>
...
</publisher>
<publisher name="publishername">
<title> booktitle </title>
<title> booktitle </title>
...
</publisher>
..
</grouped-by-publisher>
Query 3.(text search) List all the books that contain the word "web" (see the
example 1 in use case Text)
Query 4. (reformatting) Convert the bib.xml to the following format
<nbook title="Data on the Web" price=39.95>
<pub-year>
2000
</pub-year>
<authors>
lastname1
lastname2
..
</authors>
<nbook>
(extra credit:) write a DTD for this reformatted file.