1 / 27

Entity-Relationship Model Cont…..

Entity-Relationship Model Cont…. CST203-2 Database Management Systems Lecture 5. There are 2 formal languages for relational model Relational algebra Relational calculus. Relational Algebra. What is relational algebra? The result? Sequence of relational algebra Divided into 2 groups.

Download Presentation

Entity-Relationship Model Cont…..

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. Entity-Relationship ModelCont….. CST203-2 Database Management Systems Lecture 5

  2. There are 2 formal languages for relational model • Relational algebra • Relational calculus

  3. Relational Algebra

  4. What is relational algebra? • The result? • Sequence of relational algebra • Divided into 2 groups

  5. Special operations • Selection • Projection • Join • Rename • Set operations • Union • Intersection • Set difference

  6. Similar to normal algebra

  7. SELECT operation σσ<Selection Condition>(R) • σ – SELECT operator • Selection Condition : Boolean expression • R : relation • If more selection conditions, • Use ‘OR’, ‘AND’ and ‘NOT’

  8. Horizontal partition • Select the students who has the GPA greater than 3.5 σσGPA > 3.5 (STUDENT) Student Table

  9. +++++++++

  10. σ<Condition1>(σ<Condition2>(R)) = σ<Condition2>(σ<Condition1>(R)) σ<Cond1>(σ<Cond2>(σ<Cond3>(R))) = σ<Cond1> AND <Cond2> AND <Cond3>(R)

  11. Assignment • Write the relational algebra for selecting all details whose department is 4 and whose salary is greater than 30,000 • Write it in another way

  12. PROJECT operation • If want to choose a subset of the columns in a relation and discards the rest, • Use Π ΠName, GPA (Student) Π<attribute list>(R)) Π<list1>(Π<list2>(R))) = Π<list>(R))

  13. Assignment • Write the relational algebra for selecting Name, Eno, and Address

  14. Sequence of operations STU_1stCLASSΠname(σGPA > 3.5 (STUDENT))

  15. Assignment • Write the relational algebra for selecting Name, Eno, and Address of all male employees whose salary is greater than 20,000

  16. CARTESIAN PRODUCT

  17. INNER JOIN

  18. UNION operation Result 1 Πname(σGPA > 3.5 (STUDENT)) Result 2 Πname(σ(GPA > 2.5 AND GPA < 3.5) (STUDENT)) Result Result1 υ Result 2

  19. Result 1 • Result 2 • Result

  20. INTERSECTION operation Result 1 Πname(σGPA > 3.5 (STUDENT)) Result 2 Πname(σ(GPA > 2.5) (STUDENT)) Result Result1 Result 2 υ

  21. Result 1 • Result 2 • Result

  22. SET DIFFERENCE • Also called as MINUS Result Result1 – Result2

  23. Result 1 • Result 2 • Result

More Related