home / study / engineering / computer science / questions and answers / question
ID: 3832343 • Letter: H
Question
home / study / engineering / computer science / questions and answers / question 3: in these exercises, you will be working ...
Your question has been answered
Let us know if you got a helpful answer. Rate this answer
Question: Question 3: In these exercises, you will be workin...
Bookmark
Question 3:
In these exercises, you will be working with a small XML data set drawn from the Stanford course catalog. There are multiple departments, each with a department chair, some courses, and professors and/or lecturers who teach courses. The XML data is here (https://prod-c2g.s3.amazonaws.com/db/Winter2013/files/courses-noID.xml).
Write a query in XQuery
1-Return all Title elements (of both departments and courses).
2-Return last names of all department chairs.
3-Return titles of courses with enrollment greater than 500.
4-Return titles of departments that have some course that takes "CS106B" as a prerequisite.
5-Return last names of all professors or lecturers who use a middle initial. Don't worry about eliminating duplicates.
6-Return the count of courses that have a cross-listed course (i.e., that have "Cross-listed" in their description).
7-Return the average enrollment of all courses in the CS department.
8-Return last names of instructors teaching at least one course that has "system" in its description and enrollment greater than 100.
Explanation / Answer
1.doc("courses-noID.xml")//Title
OUtput:
2.doc("courses-noID.xml")//Chair//Last_Name
OUtput:
3.doc("courses-noID.xml")//Course[data(@Enrollment)>500]/Title
4.doc("courses-noID.xml")/Course_Catalog/Department[Course/Prerequisites/Prereq="CS106B"]/Title
5.doc("courses-noID.xml")//(Professor | Lecturer)[Middle_Initial]/Last_Name
6.doc("courses-noID.xml")/Course_Catalog/count(Department/Course[contains(Description,"Cross-listed")])
OUtput:
2
7.doc("courses-noID.xml")//Department[@Code="CS"]/avg(Course/@Enrollment)
OUtput:
336
8.doc("courses-noID.xml")//Course[@Enrollment>100 and contains(Description,"system")]/Instructors//Last_Name
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.