View the step-by-step solution to:

Homework 2 Thursday, March 25 1.Consider the following relational data: Products: pid Name Price Description...

Homework 2
Thursday, March 25
1.Consider the following relational data:
pid Name Price Description
p123 gizmo 22.99 great
p231 gizmoPlus 99.99 more features
p312 gadget 59.99 good value
sid Name Phones
s323 Wiz 555-1234
s521 Econo-Wiz 555-6543
sid pid Markup
s323 p231 10%
s323 p123 25%
s323 p123 15%
(a) We want to export this data into an XML file. Write a DTD describing the
following structure for the XML file:
• there is one root element called products
• the products element contains a sequence of product sub-elements, one
for each product in the database
• each product element contains one name, one price, and one description
sub-element, and a sequence of store sub-elements, one for each store that sells
that product
• each store element contains one name, one phone, and one markup subelement.
(b) Assume the relational database above is accessible through an XML interface
that exports it as:
<row> <pid>p123</pid>
<row> ... </row>
<row> ... </row>
Write an XQuery expression that, when given an input with this structure,
constructs an XML document with the structure described in part (1a).
(c) Assuming that you have XML documents with the structure given in part (1a),
write an XQuery expression that returns the names and prices of all products that
are sold at least at one store with a markup of 25%.
(d) Write the same query in SQL over the original relational database schema.
2. Consider XML data given by the following DTD:
<!ELEMENT broadway ((theater | concert | opera)*)>
<!ELEMENT theater (title, address, date, price*)>
<!ELEMENT concert (title, type, date, price*)>
<!ELEMENT opera (title, date, price*)>
(Elements that are not defined are PCDATA.) For each of the questions below
write an XPath or an XQuery query.
(a) Return all titles in the XML document
(b) Find the addresses of all theaters that have some tickets under $35 on
11/9/2008 and the titles of their show on that night.
(c) Retrieve all concert titles whose type is chamber orchestra where the average
ticket price is at least $50.
(d) Write a query that constructs a new XML document with the following
<!ELEMENT groupedByDate (day*)>
<!ELEMENT day (date, show*)>
<!ELEMENT show (title, price*)>

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors and customizable flashcards—available anywhere, anytime.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
  • -


    Browse existing sets or create your own using our digital flashcard system. A simple yet effective studying tool to help you earn the grade that you want!

    Browse Flashcards