Copyright, Harris Corporation & Ophir Frieder, Relational Definitions
Copyright, Harris Corporation & Ophir Frieder, Objectives To define basic relation terms including entity, attribute, domain, relation, relational scheme, and functional dependency.
Copyright, Harris Corporation & Ophir Frieder, Relational Terminology A domain is a set of scalar values, all of the same type. Examples: US city names- {San Diego, Miami, etc} The names of US States- {Texas, New York, etc} City populations- {1,2,3,...} (positive integers)
Copyright, Harris Corporation & Ophir Frieder, Relational Terminology, Cont. A relation is a subset of the Cartesian product of one or more domains. Example: {(San Diego,California, ), (Miami,Florida, ), (Syracuse,New York,745691)}
Copyright, Harris Corporation & Ophir Frieder, Relational Terminology, Cont. A tuple is one member of a relation. Example: (Miami,Florida, )
Copyright, Harris Corporation & Ophir Frieder, Relational Terminology, Cont. It is helpful to view a relation as a table, where each row is one tuple and each column is one attribute. Note that the relation may not actually correspond to one table in the final design - for the purposes of performance it may be combined with other tables, or broken into multiple tables. A relational scheme is the set of attributes associated with a relation.
Copyright, Harris Corporation & Ophir Frieder, Example - Relations
Copyright, Harris Corporation & Ophir Frieder, Functional Dependencies Depending on the meaning of the attributes some subsets of the Cartesian product are not valid relations.
Copyright, Harris Corporation & Ophir Frieder, Functional Dependencies, Cont. Let R be a relational scheme with attributes A 1, A 2,..., A n. Let X and Y be subsets of {A 1, A 2,..., A n }. We say that Y is functionally dependent on X in R, denoted X=>Y, if it is not possible for two distinct tuples in R to have the same value for the attributes in X, and different values for the attributes in Y. Alternatively, we say X functionally determines Y. Informally, if you know the left-hand-side, then you know the right- hand-side.
Copyright, Harris Corporation & Ophir Frieder, Functional Dependencies, Cont. SS# => NAME SS# => DATE-OF-BIRTH
Copyright, Harris Corporation & Ophir Frieder, Functional Dependencies, Cont. Note that the two functional dependencies: SS# => NAME SS# => DATE-OF-BIRTH Could be represented by the single functional dependency: SS# => NAME, DATE-OF-BIRTH Both representations have advantages, and will be used as appropriate.
Copyright, Harris Corporation & Ophir Frieder, Functional Dependencies, Cont. What are all of the possible functional dependencies for the relational scheme R=(SS#,NAME,DATE-OF-BIRTH)? Which of these hold “in the real world?”
Copyright, Harris Corporation & Ophir Frieder, Functional Dependencies, Cont. Functional dependencies are a result of what the attributes mean. A functional dependency is a statement about a relational scheme (i.e., all possible relations), and cannot be deduced from a particular relation. A functional dependency is said to be trivial if. Some functional dependencies can be enforced by a DataBase Management System (DBMS).
Copyright, Harris Corporation & Ophir Frieder, Candidate Key An Informal Definition Let R be a relational scheme. A candidate key for R is a subset of the set of attributes of R, say K, such that –Uniqueness property: No two distinct tuples of R have the same value for K. –Irreducibility property: No proper subset of K has the uniqueness property.
Copyright, Harris Corporation & Ophir Frieder, Candidate Key, Cont. SS# is a candidate key for the following. SS# => NAME SS# => DATE-OF-BIRTH
Copyright, Harris Corporation & Ophir Frieder, Candidate Key, Cont. Which of the following would be candidate keys? SS# NAME DATE-OF-BIRTH SS#, NAME SS#, DATE-OF-BIRTH NAME, DATE-OF-BIRTH
Copyright, Harris Corporation & Ophir Frieder, Candidate Key A More Formal Definition Let R be a relational scheme with attributes A 1, A 2,..., A n and functional dependencies F. In addition, let X be a subset of A 1, A 2,..., A n. Then X is a candidate key for R if –X => A 1, A 2,..., A n is in F +, and –for no proper subset Y of X is it the case that Y => A 1, A 2,..., A n is in F +.
Copyright, Harris Corporation & Ophir Frieder, Closure Of A Set Of Dependencies Question:What is F + ? Answer:F + is the closure of F - the set of all dependencies derivable from F. Equivalently, F + is the set of all dependencies that follow from F by Armstrong’s axioms.
Copyright, Harris Corporation & Ophir Frieder, Armstrong’s Axioms Tangent! Let R be a relational scheme with attributes U and functional dependencies F. Reflexivity - If Y is a subset of X, then X=>Y. Augmentation - If X=>Y, and Z is a subset of U, then XZ=>YZ. Transitivity - If X=>Y and Y=>Z, then X=>Z.
Copyright, Harris Corporation & Ophir Frieder, Keys - Additional Terminology Often times a relation will have more than one candidate key. In such cases one is sometimes designated as the primary key. Any superset of a candidate key is often times referred to as a superkey. Some authors will refer to any candidate key as simply a key, while others will use this to refer to a primary key. Throughout this course, the term key will be used synonymously with the phrase candidate key.