Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL: Multiple Tables CIT 381 2000 Oct 9. Sample Schema.

Similar presentations


Presentation on theme: "SQL: Multiple Tables CIT 381 2000 Oct 9. Sample Schema."— Presentation transcript:

1 SQL: Multiple Tables CIT 381 2000 Oct 9

2 Sample Schema

3 General Form

4 Naming Attributes

5 Renaming

6 Joins What we have been doing is computing joins, matching the shared attribute in the two tables. stud_ssn in student stud_ssn in enroll This is by far the most important and common operation.

7 Computation of Joins FROM student s, enroll e drives all pairs of rows from the two tables into the condition. WHERE s.stud_ssn=e.stud_ssn picks out those pairs that match on the desired attribute. This is sometimes called a natural join.

8 Long Join Chains Find the name of all classes taken by Alice. (We must look in three tables.) SELECT c.class_dept, c.class_num, c.class_title FROM student s, enroll e, class c WHERE s.stud_name=‘Alice’ AND s.stud_ssn=e.stud_ssn AND e.class_crn=c.class_crn;


Download ppt "SQL: Multiple Tables CIT 381 2000 Oct 9. Sample Schema."

Similar presentations


Ads by Google