1 / 16

Database Systems

Database Systems. Relational Algebra – Inner and Outer Joins. Natural join of multiple tables. Select students (Name, CGPA) who are registered in ‘Database’ course. [Note: Need to query on ‘Course Name’ and not on ‘Course Code’]

edric
Télécharger la présentation

Database Systems

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. Database Systems Relational Algebra – Inner and Outer Joins

  2. Natural join of multiple tables. • Select students (Name, CGPA) who are registered in ‘Database’ course. [Note: Need to query on ‘Course Name’ and not on ‘Course Code’] • Select Students (Name, CGPA) who are currently being taught by Ms. Saleha. • Retrieve all members (Name, Deptt Name) of ‘Publications’ committee (including its faculty incharge).

  3. Sample ERD

  4. Natural Join result • In order for a record (in one table)to appear in natural join result, its matching key (PK/FK) must exist in other table. • Records with no matching key will be filtered out during natural join.

  5. Left Outer Join

  6. Right Outer Join

  7. FULL OUTER JOIN • Mixture of Left outer join and Right outer join

  8. Sample Data

  9. Sample Scenario

  10. Exercise • Retrieve faculty information. (Faculty Name, Address, Committee Name (if any) ) • Select all students with CGPA > 3.3 and student committee they belong to. ( If a student is not part of any committee, still his name must appear in the list with committee name as ‘Null’)

  11. DIVIDE

  12. Exercise • Retrieve students who have attended all core courses of CS or of CE.

  13. Common Mistakes • Select students who are not registered in ‘CSE341’. • Incorrect: Using <> • Correct: Using DIFFERENCE • Select students who are registered in both CSE341 and CSE455. • Incorrect: Using ‘AND’ condition ( e.g. CourseCode = 341 and CourseCode = 455’ • Correct: Using Intersection • Confusion between Union and Join: • Union increases rows but Join increases columns. • Record must be present in either of table to appear in Union. Whereas in joins, PK of one table must match with FK of other table to come in resultset.

  14. Relational Calculus • Predicate & Proposition • Quantifiers • Existential Quantifier • Universal Quantifier

  15. Exercise

  16. Exercise • Select rooms that do not have dry-cleaning facility. • Retrieve rooms (RoomNo) having facilities of ‘Balcony’ and ‘Internet Connection’ but not ‘Pick & Drop’. • Retrieve rooms that do not have ‘Dry-cleaning’ facility. • Retrieve rooms (Room No, Description, Per Night Charges) that are located on either 1st or 3rd floor and have per night charges < 5000.

More Related