Skip to content

Commit

Permalink
Update assignment3-infs
Browse files Browse the repository at this point in the history
  • Loading branch information
mfzeidan committed Nov 8, 2016
1 parent ef8ecff commit 55c91e7
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions assignment3-infs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ b. A student named “John Smith” has taken the course “cs530”

let $stud := $doc.("student")[][$$.name = "John Smith"]
let $tscript := $doc.("transcript")[][$$.co = "CS530"].s


return $tscript = $stud.s

c. All students named “John Smith” has taken the course “cs530”
Expand All @@ -60,7 +58,6 @@ for $x in $doc("student")[]
where (every $name in $x.name satisfies $name eq "John Smith" )
return $x.s
)

let $search_classes := $doc("transcript")[][$$.s eq $jsmith_no].co
for $class in $search_classes
where $class eq "CS530"
Expand Down Expand Up @@ -115,29 +112,42 @@ return $class_w_pre

h. Some courses do not have prerequisites


let $course := $doc("course")[].co
let $prereqs := $doc("prereq")[].co
return $prereqs = $course


i. All classes offered this semester have prerequisites.

let $course := $doc("course")[].co
let $prereqs := $doc("prereq")[].co
return $prereqs = $course

j. Some students received only grades “A” or “B” in every course
they have taken (must appear in Transcripts)


k. All students currently involved in classes taught by professor
Brodsky (instructor = “Brodsky”) major in “CS”

let $brod := $doc("class")[][$$.instructor = "Brodsky"].co
let $brod_stud := $doc("transcript")[][$$.co = $brod].s
let $students := $doc("student")[][$$.s = $brod_stud]
for $student in $students
where (some $student in $students satisfies $student.major = "CS")
return $student.major = "CS"


l. Some students who are currently enrolled in classes taught by
professor Brodsky major in “CS”

let $q2 := $doc.("class")[][$$.instructor = "Brodsky"]
let $brod_classes := $q2
let $brod_students := $doc.("transcript")[][$$.co = $brod_classes.co]
return $brod_students
let $brod := $doc("class")[][$$.instructor = "Brodsky"].co
let $brod_stud := $doc("transcript")[][$$.co = $brod].s
let $students := $doc("student")[][$$.s = $brod_stud]
for $student in $students
where (every $student in $students satisfies $student.major = "CS")
return $student.major = "CS"

2. Write jsoniq queries to express/compute each of the following sets
(sequences) of:
Expand All @@ -156,7 +166,7 @@ return $doc("student")[][$$.s = $stud].name
b. All students named “John Smith” who have taken the course
“cs530” (must be in Transcipts)

//KINDA CORRECT
// CORRECT

let $q2 := $doc.("student")[][$$.name = "John Smith"]
let $transcripts := $doc.("transcript")[][$$.s = $q2.s][$$.co = "CS530"]
Expand All @@ -171,7 +181,6 @@ d. All students who are enrolled in a class for which they have not
satisfied all its prerequisites.



e. All students named “John Smith” who are enrolled in a class for
which they have not satisfied all its prerequisites.

Expand Down Expand Up @@ -214,13 +223,17 @@ return $classes.co
i. All students who received only grades “A” or “B” in every course
they have taken (must appear in Transcripts)

//NOT CORRECT
//eh CORRECT

let $students := $doc("student")[].s
let $transcript := $doc("transcript")[][$$.grade eq "A" or "B"]
for $x in $students
where $transcript.s = $x
return $x

let $A_OR_B :=(
for $stud in $students
where (every $grade in $doc("transcript")[].s satisfies $doc("transcript")[][$$.s = $stud][$$.grade = "A" or $$.grade = "B"])
return $stud)

return $A_or_B



j. All CS students who are currently enrolled in a class taught by
Expand Down

0 comments on commit 55c91e7

Please sign in to comment.