relational algebra basic operators
play

Relational Algebra: Basic Operators Projection (): id, name - PowerPoint PPT Presentation

Relational Algebra: Basic Operators Projection (): id, name (Students) SELECT id, name FROM <SQL for Students> Selection (): id = 100 (Students) SELECT * FROM <SQL for Students> WHERE id = 100 Join (


  1. Relational Algebra: Basic Operators ● Projection (π): π id, name (Students) → SELECT id, name FROM <SQL for Students> ● Selection (σ): σ id = 100 (Students) → SELECT * FROM <SQL for Students> WHERE id = 100 ● Join ( ⋈ ): Students ⋈ Student.id = Grades.id Grades → SELECT * FROM <SQL for Students>, <SQL for Grades> WHERE Student.id = Grades.id

  2. Relational Algebra: More operators ● Set operations ( ⋃ , ⋂ , −): Same as in SQL (UNION, INTERSECT, MINUS) Renaming ( ⍴ ): ● ⍴ S(i,n) (Students) → (SELECT id AS i, name AS n FROM Students) AS S ● Removing duplicates (δ): δ(R) → SELECT DISTINCT * FROM <SQL for R> ● Grouping/aggregation ( 𝛅 ): 𝛅 id, AVG(grade) → average (Grades) → SELECT id, AVG(grade) AS average FROM <SQL for Grades> GROUP BY id

  3. Relational Algebra: Sanity check ● Every condition, projection, etc. should ONLY mention attributes that exists in their operands. Students(idnr, name) “Select the students with at least Grades(student, course, grade) two passed courses with a grade student -> Students.idnr of at least 3” π name ( σ passed>=2 AND idnr=student AND grade>=3 (Students ⋈ γ student, COUNT(*) → passed (Grades)))

  4. Relational Algebra: Sanity check ● Every condition, projection, etc. should ONLY mention attributes that exists in their operands. Students(idnr, name) “Select the students with at least Grades(student, course, grade) two passed courses with a grade student -> Students.idnr of at least 3” π name ( σ passed>=2 AND idnr=student AND grade>=3 (Students ⋈ γ student, COUNT(*) → passed (Grades))) Can not use grade here!

  5. Relational Algebra: Sanity check ● Every condition, projection, etc. should ONLY mention attributes that exists in their operands. Students(idnr, name) “Select the students with at least Grades(student, course, grade) two passed courses with a grade student -> Students.idnr of at least 3” π name ( σ passed>=2 AND idnr=student (Students ⋈ γ student, COUNT(*) → passed We need to filter by grade before the ( σ grade>=3 (Grades)))) aggregating our data!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend