DataBase System tL Integrity of Relational Model g Comparisons with null values return the special truth value: unknown w Iffalse was used instead of unknown, then not(A <5 would not be equivalent to A>=5 e Three-valued logic using the truth value unknown E OR:(unknown or true) true (unknown or false) (unknown or unknown)=unknown H AND:( true and unknown) unknown (false and unknown) false, unknown and unknown - unknown E NOT: (not unknown)=unknown G Result of select predicate is treated as false if it evaluates to unknown Haichang Gao, Software School, Xidian University 18
DataBase System Haichang Gao , Software School , Xidian University 18 Integrity of Relational Model Comparisons with null values return the special truth value: unknown If false was used instead of unknown, then not (A < 5) would not be equivalent to A >= 5 Three-valued logic using the truth value unknown: OR: (unknown or true) = true, (unknown or false) = unknown (unknown or unknown) = unknown AND: (true and unknown) = unknown, (false and unknown) = false, (unknown and unknown) = unknown NOT: (not unknown) = unknown Result of select predicate is treated as false if it evaluates to unknown
tE Unit 2 The Relational Model Relational model H Relational algebra(关系代数) A Relational calculus(关系演算) Haichang Gao, Software School, Xidian University 19
DataBase System Haichang Gao , Software School , Xidian University 19 Unit 2 The Relational Model Relational Model Relational Algebra(关系代数) Relational Calculus(关系演算)
DataBase System Manipulation of Relational Model e Query Language is a Language in which user requests information from the database G Categories of languages a Procedural(过程化的) Non- procedural, or declarative(非过程化的,声明性的) Mathematical languages: Relational algebra(关系代数) H Tuple relational calculus((元组演算 H Domain relational calculus(域演算) G Characteristics of relational languages H all set-at-a-time(一次一集合) operands results are whole tables Closure property(封闭性) the output from one operation can become input to another Haichang Gao, Software School, Xidian University 20
DataBase System Haichang Gao , Software School , Xidian University 20 Manipulation of Relational Model Query Language is a Language in which user requests information from the database. Categories of languages Procedural(过程化的) Non-procedural, or declarative(非过程化的,声明性的) Mathematical languages: Relational algebra(关系代数) Tuple relational calculus(元组演算) Domain relational calculus (域演算) Characteristics of Relational languages all set-at-a-time (一次一集合) operands & results are whole tables Closure property(封闭性) the output from one operation can become input to another
DataBase System 6 Relational Algebra g Relational algebra is a procedural language G Basic operators select(选择):σ A project(投影)兀 A union(并):∪ H set difference(集合差): H Cartesian product(笛卡尔积) A rename: p e The operators take two or more relations as inputs and give a new relation as a result Haichang Gao, Software School, Xidian University 21
DataBase System Haichang Gao , Software School , Xidian University 21 Relational Algebra Relational algebra is a Procedural language 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 6 Basic operators G Select Operation(选择操作) Notation:σp(r) H p is called the selection predicate(条件谓词) t Defined as ()={1|t∈r^P(0)} 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 comparison operator 上 Xample of selection o branch name="perrvridgeaccount Haichang Gao, Software School, Xidian University 22
DataBase System Haichang Gao , Software School , Xidian University 22 Basic operators Select Operation(选择操作) Notation: p (r) p is called the selection predicate(条件谓词) Defined as: p (r) = {t | t r 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: =, , >, , <, (comparison operator) Example of selection: branch_name=“Perryridge” (account)