1 / 14

Relational Calculus

Relational Calculus. Logic Calculus. Logic ( 논리학 ) Propositional Calculus ( 명제계산 ), Predicate Calculus ( 술어계산 ) Propositional calculus proposition( 명제 ) can be classified as true or false Syllogism ( 삼단논법 ) If Socrates is a human, Socrates will die. (p->q) Socrates is a human. (p)

Download Presentation

Relational Calculus

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Relational Calculus

  2. Logic Calculus • Logic (논리학) Propositional Calculus (명제계산),Predicate Calculus (술어계산) • Propositional calculus proposition(명제) can be classified as true or false Syllogism (삼단논법) If Socrates is a human, Socrates will die. (p->q) Socrates is a human. (p) Socrates will die. ( (p->q)∧p) -> q 데이터베이스시스템

  3. Syllogism (삼단논법) Truth table(진리표) • Predicate Calculus propositional calculus + quantifiers such as EXISTS, FORALL 데이터베이스시스템

  4. Predicate Calculus • 예 : 모든 사람은 죽는다.Socratest는 사람이다.따라서, Socrates는 죽는다.propositional calculus로는 증명할 수 없다. • 증명 H(x) : x는 사람이다. M(x) : x는 죽는다. • ( x) (H(x) –> M(x)) • H(s) • H(s) –> M(s) by 1) & 2) Universal Instantiation • M(s) by 2) & 3) propositional logic 데이터베이스시스템

  5. Relational Algebra vs. Relational Calculus • Algebra operators are applied to relations in a specified order (procedural) • Calculus select all the tuples which make the specified condition true (non-procedural) tuple calculus vs. domain calculus 데이터베이스시스템

  6. Relational Calculus • Tuple variable a variable which represents a tuple of a relation x  학생(학번, 이름, 학년, 학과) y  과목(과목번호, 과목이름, 학점수, 학과, 담당교수) z  수강(학번, 과목번호, 성적, 중간성적, 기말성적) • Examples • List all the student names.x  학생, { x.이름 } • List the student_numbers of students who take ‘C413’ z  수강, { z.학번 | z.과목번호= ‘C413’ } 데이터베이스시스템

  7. 집합 표시 데이터베이스시스템

  8. Relational Calculusx  학생 (학번, 이름, 학년, 학과)y  과목(과목번호, 과목이름, 학점수, 학과, 담당교수)z  수강(학번, 과목번호, 성적, 중간성적, 기말성적) • List the names and the departments of students who are not in ‘컴퓨터’departmentx  학생, { (x.이름, x.학과) | x.학과<> ‘컴퓨터’} • List the student_number and class_numberpairs such that indicated student got higher than or equal to 90 in either the midterm or the final of the indicated classz  수강, { (z.학번, z.과목번호) | z.중간성적>= 90 or z.기말성적>= 90 } 데이터베이스시스템

  9. Relational Calculusx  학생 (학번, 이름, 학년, 학과)y  과목(과목번호, 과목이름, 학점, 학과, 담당교수)z  수강(학번, 과목번호, 성적, 중간성적, 기말성적) • List the student_numbers of students who got ‘A’ in the class ‘C413’z  수강, { z.학번 | z.과목번호= ‘C413’ and z.학점= ‘A’ } • List the names and departments of students who take ‘C413’ x  학생, z  수강, { (x.이름, x.학과) | EXISTS z (z.학번=x.학번 and z.과목번호= ‘C413’) } join  In  EXISTS 데이터베이스시스템

  10. Relational Calculusx  학생 (학번, 이름, 학년, 학과)y  과목(과목번호, 과목이름, 학점, 학과, 담당교수)z  수강(학번, 과목번호, 성적, 중간성적, 기말성적) • Find the student name which comes first in the alphabetical order. x1, x2  학생, { x1.이름| FORALL x2 (x1.이름 <= x2.이름) } • Quantifiers (정량자) EXISTS V(p) (existential quantifier, 존재정량자) : There exists at least one value V that makes p true. FORALL V(p) (univeral quantifier, 범용정량자) : For all values of V, p evaluates true. 데이터베이스시스템

  11. Relational Calculusx  학생 (학번, 이름, 학년, 학과)y  과목(과목번호, 과목이름, 학점, 학과, 담당교수)z  수강(학번, 과목번호, 성적, 중간성적, 기말성적) • List the student_numbersand the names of students who do not take ‘C413’. x  학생, z  수강, { (x.학번, x.이름)| NOT EXISTS z (z.학번=x.학번 and z.과목번호= ‘C413’ )}Difference  Not In  Not EXISTS • List the names of students who take at least one class from ‘컴퓨터’departmentx  학생, y 과목, z  수강, { x.이름| EXISTS z (z.학번=x.학번 and EXISTS y (y.과목번호 = z.과목번호 and y.학과= ‘컴퓨터’) ) } 데이터베이스시스템

  12. Relational Calculusx  학생 (학번, 이름, 학년, 학과)y  과목(과목번호, 과목이름, 학점, 학과, 담당교수)z  수강(학번, 과목번호, 성적, 중간성적, 기말성적) • List the names of students who take at least one class together with the student of student_number 100. x  학생, z1  수강, z2  수강, { x.이름| EXISTS z1 (z1.학번=x.학번 and EXISTS z2 (z2.과목번호= z1.과목번호 and z2.학번= 100 ) ) } • List the names of students who take all the listed classes in 과목 relation Algebra : ( 수강[학번, 과목번호] / 과목[과목번호] )Join 학생 ) [이름]Calculusx  학생, y 과목, z  수강, { x.이름| FORALL y (EXISTS z ( z.과목번호= y.과목번호 and z.학번=x.학번) )} 데이터베이스시스템

  13. Relational Calculusx  학생 (학번, 이름, 학년, 학과)y  과목(과목번호, 과목이름, 학점, 학과, 담당교수)z  수강(학번, 과목번호, 성적, 중간성적, 기말성적) ( 수강[학번, 과목번호] / 과목[과목번호] ) join 학생 ) [이름] x  학생, y 과목, z  수강, { x.이름| FORALL y (EXISTS z ( z.과목번호= y.과목번호 and z.학번=x.학번} FORALL V(p)  NOT EXISTS V(Not p) { x.이름| Not EXISTS y (Not EXISTS z ( z.과목번호= y.과목번호 and z.학번=x.학번} Denominator is the relation for the first NOT EXISTS. 데이터베이스시스템

  14. Relational Calculusx  학생 (학번, 이름, 학년, 학과)y  과목(과목번호, 과목이름, 학점, 학과, 담당교수)z  수강(학번, 과목번호, 성적, 중간성적, 기말성적) FORALL V(p)  NOT EXISTS V(Not p) All dogs are animals  There are no dogs which are not animals takes all the subjects  There are no subjects which are not taken Names of students  Names of students who take such that all the subjects there are no subjects not taken by each of them. 데이터베이스시스템

More Related