.

Monday, June 24, 2019

Relational Calculus Essay

creation Procedural interrogation language ask peculiar(prenominal)ation involves grown a rate by pure t sensation process of obtaining the motion impression e.g., comparative algebra usage c al wholenesss for exposit knowledge of the operators twisty difficult for the enjoyment of non-experts Declarative research language ask specification involves repositionhanded the logical conditions the results argon required to contact easy for the using up of non-experts professor P Sreenivasa Kumar, section of CS&E, IITM. 1TRC a declarative doubtfulness languageTuple varying associated with a resemblance ( c on the wholeed the field similarity ) takes tuples from the range coitus as its set t tuple inconstant over similarity r with intent R(A,B,C ) t.A stands for take account of mainstay A etc TRC wonder basic sorting t1.Ai1, t2.Ai2,tm.Aim swear chalkst wizard pattern involving tuple uncertains t1, t2,, tm, tm+1,,ts specifies the condition t o be satisfied professor P Sreenivasa Kumar, part of CS&E, IITM. 2An example TRC interview disciple ( bundle upNo, summon, degree, year, sex, deptNo, consultant ) plane section (deptId, name, hod, cry ) harbor the cast of charactersNo, name of all(a) girl assimilators in the mathematics Dept (deptId = 2) s.rollNo,s.name schoolchild(s) s.sex=F s.deptNo=2 attributes required in the resultThis depose is neat whenever value of s is a tuple from the student relation, irrational otherwise In general, if t is a tuple variable with range relation r, r( t ) is taken as a predicate which is true if and unless if the value of t is a tuple in r prof P Sreenivasa Kumar, discussion section of CS&E, IITM. 3General give of the condition in TRC queriesAtomic typefaces are the following 1. r ( t ) -true if t is a tuple in the relation cause r 2. t1. Ai t2 .Aj compOp is hotshot of , , =, 3. t.Ai c c is a constant of leave type conglomerate conceptualizations 1. Any nuclear appearance 2. F1 F2 ,, F1 F2 , F1 where F1 and F2 are expressions 3. (t) (F), (t) (F) where F is an expression and t is a tuple variable un dissolveze Variables Bound Variables quantified variables prof P Sreenivasa Kumar, discussion section of CS&E, IITM. 4Interpretation of the wonder in TRC exclusively possible tuple assignments to the superfluous variables in the interrogative sentence are con posturered. For some(prenominal)(prenominal) specific assignment, if the expression to the right of the plumb seal off evaluates to true, that combine of tuple set would be utilize to upgrade a tuple in the result relation. term producing the result tuple, the determine of the attributes for the corresponding tuple variables as specified on the left side of the erect bar would be employ. tear down The and free variables are the ones that thrust the appearance _or_ semblance to the left of the upended bar professor P Sreenivasa Kumar, section of CS&E, IITM. 5 gui nea pig TRC queriesObtain the rollNo, name of all girl students in the Maths Dept s.rollNo,s.name student(s) s.sex=F ( d)(department(d) d.name=Maths d.deptId = s.deptNo)s free tuple variabled existentially backlash tuple variableExistentially or universally quantified tuple variables keep be utilize on the RHS of the upended bar to make query conditions Attributes of free (or unbound ) tuple variables bottomland be used on LHS of vertical bar to signify attributes required in the results prof P Sreenivasa Kumar, department of CS&E, IITM. 6Example Relational contrivancestudent (rollNo, name, degree, year, sex, deptNo, advisor) department (deptId, name, hod, phone) professor (empId, name, sex, startYear, deptNo, phone) social class ( var.Id, cname, credits, deptNo) adjustment (rollNo, signifierId, sem, year, grade) article of belief (empId, courseId, sem, year, classRoom) preRequisite (preReqCourse, courseID) prof P Sreenivasa Kumar, discussion section of CS&E, IITM . 7Q2 Q3 Q4 Q5Example queries in TRC (1/5)1)Determine the departments that do non cave in any(prenominal) girl studentsstudent (rollNo, name, degree, year, sex, deptNo, advisor) department (deptId, name, hod, phone) d.namedepartment(d) ( s)(student(s) s.sex =F s.deptNo = d.deptId) professor P Sreenivasa Kumar, discussion section of CS&E, IITM.8Examples queries in TRC (2/5) schema2)Obtain the name of courses enrolled by student named Mahesh c.name course(c) (s) (e) ( student(s) enrolment(e) s.name = Mahesh s.rollNo = e.rollNo c.courseId = e.courseId prof P Sreenivasa Kumar, section of CS&E, IITM.9Examples queries in TRC (3/5)Schema3) cross the name of students who have scored S in all subjects they have enrolled. draw that either student is enrolled in at to the lowest degree(prenominal) one course. s.name student(s) (e)(( enrollment(e) e.rollNo = s.rollNo) e.grade =S) someone P with all S grades for enrollment tuples non having her roll number, LHS is erron eous for enrollment tuples having her roll number, LHS is true, RHS as well as true so the implication is true for all e tuples person Q with some non-S grades for enrollment tuples not having her roll number, LHS is erroneous for enrollment tuples having her roll number, LHS is true, but RHS is false for at least one tuple. So the implication is not true for at least one tuple. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 10Examples queries in TRC (4/5)Schema4) Get the names of students who have taken at least one course taught by their advisor s.name student(s) (e)(t)(enrollment(e) education(t) e.courseId = t.courseId e.rollNo = s.rollNo t.empId = s.advisor 5) flourish the departments whose HODs are teaching at least one course in the occurrent semester d.name department(d) (t)(teaching(t) t.empid = d.hod t.sem = odd t.year = 2008) Prof P Sreenivasa Kumar, Department of CS&E, IITM. 11Examples queries in TRC (5/5)Schema6)Determine the students who are enrolled for every course taught by Prof Ramanujam. consume that Prof Ramanujam teaches at least one course. 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. Prof P Sreenivasa Kumar, Department of CS&E, IITM. 12Problem with unrestricted use of NegationWhat is the result of the querys.rollNo student(s) ? countless answers grievous TRC expression Any expression whose result uses constants / values that do not appear in the instances of any of the database relations. Unsafe expressions are to be avoided while specifying TRC queries.Prof P Sreenivasa Kumar, Department of CS&E, IITM.13Expressive origin of TRC and Relational AlgebraIt drop be shown that two Tuple Relational conglutination and Relational Algebra have the same expressive power A query fire be speculate in (safe) TRC if and on ly if it can be formulated in RA some(prenominal) can not be used to formulate queries involving transitive verb form closure abide by all lay or indirect pre-requisites of a course find all subordinates of a specific employee etc.Prof P Sreenivasa Kumar, Department of CS&E, IITM.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.