Relational Algebra Procedural language Six basic operators select project union set difference Cartesian product rename The operators take two or more relations as inputs and give a new relation as a result Database System Concepts 3.16 OSilberschatz, Korth and Sudarshan
Database System Concepts 3.16 ©Silberschatz, Korth and Sudarshan Relational Algebra Procedural language Six basic operators select project union set difference Cartesian product rename The operators take two or more relations as inputs and give a new relation as a result
Select Operation- Example Relation r ABCD aa 1 7 B57 BB123 BB2310 =BaD>so ABC D 17 BB2310 Database System Concepts 3.17 OSilberschatz, Korth and Sudarshan
Database System Concepts 3.17 ©Silberschatz, Korth and Sudarshan Select Operation – Example • Relation r A B C D 1 5 12 23 7 7 3 10 • A=B ^ D > 5 (r) A B C D 1 23 7 10
Select Operation Notation:σp( p is called the selection predicate Defined as: (门={ I and p(t) Where p is a formula in propositional calculus consisting of terms connected by :A(and),v(or) (not Each term is one of: <attribute> op <attribute> or <constant> where op is one of:=,≠>≥.<≤ Example of selection: O branch-name=Perryridge(account) Database System Concepts 3.18 OSilberschatz, Korth and Sudarshan
Database System Concepts 3.18 ©Silberschatz, Korth and Sudarshan Select Operation Notation: p (r) p is called the selection predicate Defined as: p (r) = {t | t r and p(t)} Where p is a formula in propositional calculus consisting of terms connected by : (and), (or), (not) Each term is one of: <attribute> op <attribute> or <constant> where op is one of: =, , >, . <. Example of selection: branch-name=“Perryridge”(account)
Result of o branch-name ="Perryridge"(loan) loan-number branch-name amount L-15 Perryridge 1500 L-16 Perryridge 1300 标 Database System Concepts 3.19 OSilberschatz, Korth and Sudarshan
Database System Concepts 3.19 ©Silberschatz, Korth and Sudarshan Result of branch-name = “Perryridge” (loan)
Project Operation Example Relation r ABC a101 a201 B301 B402 IAC(O AC AC aaββ 1112 B 1 B2 Database System Concepts 3.20 OSilberschatz, Korth and Sudarshan
Database System Concepts 3.20 ©Silberschatz, Korth and Sudarshan Project Operation – Example Relation r: A B C 10 20 30 40 1 1 1 2 A C 1 1 1 2 = A C 1 1 2 A,C (r)