1 Section 10.4.1 Relational Algebras A relational algebra consists of a set of relations together with operations to construct new relations. We’ll describe.

Slides:



Advertisements
Similar presentations
primary key constraint foreign key constraint
Advertisements

Relations Relations on a Set. Properties of Relations.
Chapter 3 : Relational Model
SECTION 21.5 Eilbroun Benjamin CS 257 – Dr. TY Lin INFORMATION INTEGRATION.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Instructor: Hayk Melikya
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Relational Algebra Ch. 7.4 – 7.6 John Ortiz. Lecture 4Relational Algebra2 Relational Query Languages  Query languages: allow manipulation and retrieval.
Relational Algebra 1 Chapter 5.1 V3.0 Napier University Dr Gordon Russell.
Discrete Structures Chapter 2 Part A Sequences Nurul Amelina Nasharuddin Multimedia Department.
SET.   A set is a collection of elements.   Sets are usually denoted by capital letters A, B, Ω, etc.   Elements are usually denoted by lower case.
Chapter 5 Section 1 Sets Basics Set –Definition: Collection of objects –Specified by listing the elements of the set inside a pair of braces. –Denoted.
Discrete Structures Chapter 3 Set Theory Nurul Amelina Nasharuddin Multimedia Department.
Operations in the Relational Model These operation can be expressed in an algebra, called “relational algebra”. In this algebra relations are the operands.
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 12 Number theory Mathematical induction Proof by induction Examples.
Equivalence Relations: Selected Exercises
Hawkes Learning Systems: College Algebra
Math 3121 Abstract Algebra I Lecture 3 Sections 2-4: Binary Operations, Definition of Group.
1 Section 10.1 What Is an Algebra? To most people the word algebra means high school algebra. But there are many kinds of algebra. An algebra consists.
(CSC 102) Lecture 15 Discrete Structures. Previous Lectures Summary  Procedural Versions  Properties of Sets  Empty Set Properties  Difference Properties.
April 10, 2002Applied Discrete Mathematics Week 10: Relations 1 Counting Relations Example: How many different reflexive relations can be defined on a.
1 Chapter Elementary Notions and Notations.
1 Chapter Regular Language Topics. 2 Section 11.4 Regular Language Topics Regular languages are also characterized by special grammars called regular.
Relational Algebra – Constraints CIS 4301 Lecture Notes Lecture /02/2006.
Relational Algebra (Chapter 7)
The Relational Algebra and Calculus
Chapter 7: Relations Relations(7.1) Relations(7.1) n-any Relations & their Applications (7.2) n-any Relations & their Applications (7.2)
CS201: Data Structures and Discrete Mathematics I
CompSci 102 Discrete Math for Computer Science
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Advanced Relational Algebra & SQL (Part1 )
1 Introduction to Abstract Mathematics Sets Section 2.1 Basic Notions of Sets Section 2.2 Operations with sets Section 2.3 Indexed Sets Instructor: Hayk.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
Chapter 2 With Question/Answer Animations. Section 2.1.
Presented By: Miss N. Nembhard. Relation Algebra Relational Algebra is : the formal description of how a relational database operates the mathematics.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 10 A First Course in Database Systems.
1 CS 430 Database Theory Winter 2005 Lecture 5: Relational Algebra.
Section 11.4 Regular Language Topics
Functions (Mappings). Definitions A function (or mapping)  from a set A to a set B is a rule that assigns to each element a of A exactly one element.
1 Section 1.2 Sets A set is a collection of things. If S is a set and x is a member or element of S we write x  S. Othewise we write x  S. The set with.
CS 285- Discrete Mathematics
SECTION 10 Cosets and the Theorem of Lagrange Theorem Let H be a subgroup of G. Let the relation  L be defined on G by a  L b if and only if a -1 b 
N-ary Relations & Their Applications. 2 n-ary Relations Let A 1, A 2, …, A n be sets. An n-ary relation on these sets is a subset of A 1 x A 2 x … x A.
Section 3.3 Proving set properties. Element-wise set proofs Claim. For all sets A and B, (A  B)  A. Proof. Let sets A and B be given. Since every element.
1 Section 11.1 Regular Languages Problem: Suppose the input strings to a program must be strings over the alphabet {a, b} that contain exactly one substring.
1 Chapter Regular Languages. 2 Section 11.1 Regular Languages Problem: Suppose the input strings to a program must be strings over the alphabet.
Set Operations Section 2.2.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
6.5 Proving the Pythagorean Theorem.  Objectives  Prove the Pythagorean Theorem using similar triangles  Prove the Converse of the Pythagorean Theorem.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts - 6 th Edition Chapter 8: Relational Algebra.
Math 3121 Abstract Algebra I Lecture 6 Midterm back over+Section 7.
Equivalence Relations: Selected Exercises
Module 2: Intro to Relational Model
Applied Discrete Mathematics Week 10: Relations
CSE 504 Discrete Structures & Foundations of Computer Science
Set Operations Section 2.2.
CS2210 Discrete Structures Relations
Applied Discrete Mathematics Week 5: Boolean Algebra
Relational Data Base Design in Practice
Applied Discrete Mathematics Week 6: Relations/Digraphs
Linear Algebra Chapter 4 Vector Spaces.
Solving Equations and Inequalities with Absolute Value
Solving Equations and Inequalities with Absolute Value
Chapter 2: Intro to Relational Model
Chapter 6: Formal Relational Query Languages
Example of a Relation attributes (or columns) tuples (or rows)
Chapter 2: Intro to Relational Model
Equivalence Relations: Selected Exercises
Unit Relational Algebra 1
Lecture 2 Relational Database
Presentation transcript:

1 Section Relational Algebras A relational algebra consists of a set of relations together with operations to construct new relations. We’ll describe the three operations select, project, and join. Select Operation: Let R be a relation, A an attribute, and a a possible element of some tuple. Then select(R, A, a) is the subset of tuples with a in the Ath position. So we have select(R, A, a) = {t  R | t(A) = a}. Project Operation: Let R be a relation with attribute set I and X  I. Then project(R, X) is the set of tuples indexed by X and constructed from tuples of R by deleting components with attributes in I – X. So we have project(R, X) = {s |  t  R  A  X (s(A) = t(A))}. Join Operation: Let R and S be relations with attribute sets I and J. Then the join(R, S) is the relation with attribute set I  J defined by join(R, S) = {t |  r  R  s  S  A  I  B  J (t(A) = r(A))  (t(B) = s(B))}. Example.

2 Example/Quiz (1 minute). Use the Students database to construct two databases C and M for the CS department database and the Math department database. Answer:C = select(Students, Major, CS) and M = select(Students, Major, Math). Example/Quiz (1 minute). Use the Students database to construct the database D of the names, id’s, and credits of students who are double majoring in math and CS. Answer: Let A = project(C, {Name, ID, Credits}) and B = project(M, {Name, ID, Credits}). Then D = join(A, B). Example/Quiz (1 minute). From the database Family, who are the children of Thomas? Answer: project(select(Family, Father, Thomas), {Name}) Example/Quiz (1 minute). From the database Family, who are B. Franklin’s parents? Answer: project(select(Family, Name, B. Franklin), {Mother, Father}) Example/Quiz (1 minute). From the database Family, who are children by Jane and Peter? Answer: project(select(select(Family, Father, Peter), Mother, Jane), {Name}).

3 Properties Notation: join(R, S) is sometimes denoted R  S. R  R = R join is associative: (R  S)  T = R  (S  T) select(select(R, A, a), B, b) = select(select(R, B, b), A, a). project(select(R, A, a), X) = select(project(R, X), A, a) if and only if A  X. Let I and J be the attribute sets for R and S. If I  J = , then join(R, S) = R  S. If I = J, then the following four properties hold: (a) join(R, S) = R  S. (b) select(R  S, A, a) = select(R, A, a)  select(S, A, a). (c) select(R  S, A, a) = select(R, A, a)  select(S, A, a). (d) select(R – S, A, a) = select(R, A, a) – select(S, A, a). Example. Prove that join is associative: (R  S)  T = R  (S  T). Proof: Let I, J, K be the attribute sets of R, S, T. Let x  (R  S)  T. Then there exist tuples u  (R  S) and t  T such that x(A) = u(A) for all A  I  J and x(A) = t(A) for all A  K. Since u  (R  S) there exist tuples r  R and s  S such that u(A) = r(A) for all A  I and u(A) = s(A) for all A  J. So we have x(A) = r(A) for all A  I, x(A) = s(A) for all A  J, and x(A) = t(A) for all A  K. Let w  S  T be defined by w(A) = s(A) for all A  J and w(A) = t(A) for all A  J. So we have x(A) = w(A) for all A  J  K. Since x(A) = r(A) for all A  I, it follows that x  R  (S  T). Therefore (R  S)  T  R  (S  T). The other containment is similar. Do it as an exercise. QED.