Use the document structure described in Exercise 15.23 to formulate the following queries in XQuery:

a. List all classes (identi?ed by a course code and semester) where every student received a B or higher.
b. List all students who never received less than a B.


a.


DECLARE FUNCTION classesFromTranscripts($elts AS element()*) AS element()*
{
FOR $e IN $elts
RETURN

{ $e//CrsCode, $e//Semester }

}


{
LET $transcripts := doc("http://xyz.edu/transcript.xml")
FOR $c IN
distinct-values(classesFromTranscripts($transcripts//tuple))
LET $grades :=
doc("http://xyz.edu/transcript.xml")
//tuple[CrsCode/@value=$c/CrsCode/@value
and Semester/@value=$c/Semester/@value]
/Grade/@value
WHERE EVERY $g IN $grades
SATISFIES numericGrade($g) >= numericGrade("B")
RETURN $c
}



b.

DECLARE FUNCTION classesFromTranscripts($elts AS element()*) AS element()*
{
FOR $e IN $elts
RETURN

{ $e//CrsCode, $e//Semester }

}


{
LET $transcripts := doc("http://xyz.edu/transcript.xml")
FOR $sid IN
distinct-values(classesFromTranscripts($transcripts//tuple)),
$s IN doc("http://xyz.edu/student.xml")
//tuple[Id/@value=$sid/StudId/@value]
LET $grades :=
$transcripts//tuple[StudId/@value=$sid/StudId/@value]/Grade/@value
WHERE EVERY $g IN $grades
SATISFIES numericGrade($g) >= numericGrade("B")
RETURN $s
}

Computer Science & Information Technology

You might also like to view...

You have a program with a class that is separated into files. The implementation has been changed. Of the interface file, the implementation file and the application file, which must be recompiled?

a) Only the interface? b) Only the implementation? c) Only the Application? d) None of the above? e) Some of the above?

Computer Science & Information Technology

When you are developing a chart, PowerPoint opens Microsoft Excel if that software is installed on your system.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Ethernet backbone networks must use a high-speed switch.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

By default, Outlook stores tasks in the ____________________ folder.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology