5-Algebra

5-Algebra - CS273 - Data and Knowledge Bases Xifeng Y Xif...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CS273 - Data and Knowledge Bases Xifeng Yan Computer Science niversity of California at Santa Barbara University of California at Santa Barbara
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Department of Computer Science Query Relational Databases We have discussed SQL, the industry-standard query language, for relational databases. We will discuss two formal query languages Relational algebra is a procedural language, giving the perations to retrieve the data from the database operations to retrieve the data from the database. Relational calculus is a declarative (nonprocedural) query language, indicating the properties of the data to retrieve from the database. CS273: Data and Knowledge Bases | University of California at Santa Barbara 2 slides by courtesy of Y. Chen with modifications
Background image of page 2
Department of Computer Science Outline Six Fundamental Operators Union ifference Difference Cartesian_product Selection Projection Rename Additional Operators Intersection -join natural_join division CS273: Data and Knowledge Bases | University of California at Santa Barbara 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Department of Computer Science SIX FUNDAMENTAL OPERATORS Let r and s be relations with schemas R and S, spectively respectively union: r s={t|t r t s} difference: r-s= { t | t r t s} cartesian_product: r s={t|t=t r t s where t r r t s selection: P (r) projection: A (r) rename: (x) CS273: Data and Knowledge Bases | University of California at Santa Barbara 4
Background image of page 4
Department of Computer Science UNIVERSITY EXAMPLE chema & Instance Schema & Instance eee_majors cse_majors id l id name class 2222 Student2 SO 444 t dent4 SR id class 1111 Student1 FR 2222 Student2 4444 Student4 6666 Student6 SR 3333 Student3 JR 4444 Student4 5555 Student5 GR cse_profs name office cse_courses crsid crstitle teaches tname tcrsid Prof1 Office1 Prof2 Office2 CSE412 Database Management CSE513 Rules in Database Systems CSE514 Object Oriented Databases Prof1 CSE412 Prof1 CSE513 Prof2 CSE514 CS273: Data and Knowledge Bases | University of California at Santa Barbara 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Department of Computer Science NION ={t|t } UNION : r s = { t | t r t s } Compatibility Restriction: r and s must be compatible EXAMPLE Query: List the student information for the relations r and s must be of the same number of attributes the domains of the ith attribute either computer science or electrical engineering majors. Answer: se majors ee majors of r must be the same as the ith attribute of s Philosophy: ou shouldn't union together cse_majors eee_majors Schema: { id, name, class } You shouldn t union together relations that don't belong together. CS273: Data and Knowledge Bases | University of California at Santa Barbara 6
Background image of page 6
Department of Computer Science UNION: Example Query Result id name class 1111 Student1 FR 222 tudent2 SO 2222 Student2 3333 Student3 JR 4444 Student4 SR 555 t dent5 GR 5555 Student5 6666 Student6 CS273: Data and Knowledge Bases | University of California at Santa Barbara 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Department of Computer Science IFFERENCE: - ={t|t } DIFFERENCE: r s { t | t r t
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/09/2012 for the course CS CS273 taught by Professor Xifengyan during the Spring '11 term at UCSB.

Page1 / 35

5-Algebra - CS273 - Data and Knowledge Bases Xifeng Y Xif...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online