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 14, 2016
1 parent cfe6dd0 commit 7b0af7f
Showing 1 changed file with 22 additions and 29 deletions.
51 changes: 22 additions & 29 deletions assignment3-infs
Original file line number Diff line number Diff line change
Expand Up @@ -95,46 +95,39 @@ return $prereqs.co = $prereqs.co
f. Every student who majors in “CS” has satisfied all prerequisites for
each class she is enrolled in.

//looks better
//CORRECT BUT CHECK

return every $st in $doc.students[][$$.major = "CS"]
satisfies (every $e in $doc.enrolled[], $prereq in $doc.prereq[]
satisfies ($e.s = $st.s
and $prereq.pre = $e.cl))


every $st in $db.student[]
and every $e in $db.enrolled[]
and every $prereq in $db.prereq[]
where $db.major = "CS" and $st.s = $s.d and $e.course = $prereq.course}
let $classes := (
for $x in $doc.transcript[]
where $x.s = $doc.student[][$$.major = "CS"].s
return $x)

satisfies ($t in $db.transcript[] satisfies $t.student = $st.s and $t.course - $st.course)
let $prereqs :=(
for $x in $classes
where (every $c in $doc.prereq[]
satisfies $c.pre = $x.co)
return $x)
return $prereqs.co = $prereqs.co


g. A student named “John Smith” is enrolled in a class for which he
did satisfied all prerequisites.

//eh

let $jsmith_no :=(
for $x in $doc("student")[]
where (every $name in $x.name satisfies $name eq "John Smith" )
return $x.s
)
let $jsmith_tscript := (
for $x in $jsmith_no
return $doc("transcript")[][$$.s eq $x]
)

let $jsmith_classes:=
(
for $x in $jsmith_tscript
return $x.co)
//CORRECT BUT CHECK AGAIN

let $class_w_pre := $doc("prereq")[].co

return $class_w_pre = $class_w_pre
let $classes := (
for $x in $doc.transcript[]
where $x.s = $doc.student[][$$.name = "John Smith"].s
return $x)

let $prereqs :=(
for $x in $classes
where (some $c in $doc.prereq[]
satisfies $c.pre = $x.co)
return $x)
return $prereqs.co = $prereqs.co

h. Some courses do not have prerequisites

Expand Down

0 comments on commit 7b0af7f

Please sign in to comment.