The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+1 vote
319 views
Example Relational Scheme
student (rollNo, name, degree, year, sex, deptNo, advisor)
department (deptId, name, hod, phone)
professor (empId, name, sex, startYear, deptNo, phone)
course (courseId, cname, credits, deptNo)
enrollment (rollNo, courseId, sem, year, grade)
teaching (empId, courseId, sem, year, classRoom)
preRequisite (preReqCourse, courseID)

Question:

Determine the students who are enrolled for every
course taught by Prof Ramanujam. Assume that Prof
Ramanujam teaches at least one course.

Answer:

1. {s.rollNo | student (s) ^
2. (∀c)(course (c) ^
3. ((∃t),(∃p)( teaching(t) ^ professor(p) ^
4. t.courseId = c.courseId ^
5. p.name = “Ramanujam” ^
6. p.empId = t.empId )) →
7. (∃e) (enrollment(e) ^
8. e.courseId = c.courseId ^
9. e.rollNo = s.rollNo)
10. )
11. }

 

Please explain the answer, i am little bit confused with how relation calculus express divide operator.

(My belief if that ∀ is similar to the quotient operator. ) TIA !
asked in Databases by Active (3.3k points)
edited by | 319 views

1 Answer

0 votes

As you have mentioned in the question, this is a relational calculus expression and not a relational algebra one. Relational algebra contains only algebraic operations and proportional logic. But relational calculus can contain free and bound variables as seen here. 

$\forall$ means FORALL $\exists$ means EXISTS as in Mathematical logic

1. {s.rollNo | student (s) ^
2. (∀c)(course (c) ^
3. ((∃t),(∃p)( teaching(t) ^ professor(p) ^
4. t.courseId = c.courseId ^
5. p.name = “Ramanujam” ^
6. p.empId = t.empId )) →
7. (∃e) (enrollment(e) ^
8. e.courseId = c.courseId ^
9. e.rollNo = s.rollNo)
10. )
11. }
This says that for all courses taught by Ramanugan if there exists a student who has enrolled for it, then return his id. If you go through each line carefully you can get this. 


Relational Algebra and relational calculus:
http://www.cs.virginia.edu/~son/cs662.s06/ch4m.ppt

answered by Veteran (370k points)

Related questions

0 votes
2 answers
1
0 votes
0 answers
7


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

44,510 questions
49,968 answers
165,819 comments
65,915 users