Download presentation
Presentation is loading. Please wait.
Published byPaulina Cunningham Modified over 9 years ago
1
Relational Algebra – Constraints CIS 4301 Lecture Notes Lecture 15 - 3/02/2006
2
Lecture 15© CIS 4301 - Spring 20062 Dependent and Independent Operations R S = R - (R-S) R thetajoin C S = C (R x S) R nat join S = L ( C (R x S)), L is a list of attributes in R followed by attributes in S which are not also in R C is a condition of the form R.A 1 = S.A 1 AND R.A 2 = S.A 2 AND … R.A n =S.A n, where A 1, A 2, A n are all the attributes in the schemas of both R and S
3
Lecture 15© CIS 4301 - Spring 20063 Constraints on Relations Convenient way to express a variety of constraints on relational schema, incl. ref. integrity Two ways: Let R, S be expressions of rel. algebra, R = “There are no tuples in the result of R” R S“Every tuple in the result of R must also be in the result of S” SQL programming uses the “equal-to-empty style”
4
Lecture 15© CIS 4301 - Spring 20064 Referential Integrity Movie (Title,Year,length,filmType, studioName,producerC#) MovieExec(name,address,Cert#,netWorth) Want to express the fact that producerC# of every movie tuple must also appear in the cert# component of some MovieExec tuple (i.e., ref. Integrity constraint) Use rel. algebra producerC# (Movie) cert# (MovieExec) producerC# (Movie) - cert# (MovieExec) =
5
Lecture 15© CIS 4301 - Spring 20065 Functional Dependency MovieStar(name,address,gender, birthdate) How do we express FD: name address
6
Lecture 15© CIS 4301 - Spring 20066 Sample Schema for Exercises Student(ID, name, address, GPA, SAT) Campus(location, enrollment, rank) Apply(ID, location, date, major, decision)
7
Lecture 15© CIS 4301 - Spring 20067 Exercises PROJECT {date,decision} (Apply) Campus x Apply Find Names and addresses of all students with GPA > 3.7 who applied to CS major and were rejected Find the enrollment and rank for each campus to which a student with id=“12345” applied
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.