{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

5-Algebra

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

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

CS273 - Data and Knowledge Bases Xifeng Yan Computer Science niversity of California at Santa Barbara University of California at Santa Barbara

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
Department of Computer Science IFFERENCE: - ={t|t } DIFFERENCE: r s { t | t r t
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 35

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

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

View Full Document
Ask a homework question - tutors are online