Академический Документы
Профессиональный Документы
Культура Документы
Kroenkes
Database Processing:
Fundamentals, Design, and Implementation
Objetivos
Comprender terminologa relacional Comprender caractersticas de RELACIONES Comprender alternativas para describir el modelo relacional Identificar DEPENDENCIAS FUNCIONALES, DETERMINANTES y ATRIBUTOS DEPENDIENTES Identificar llaves candidato, primarias, compuestas, y surrogate
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall 3-2
Objetivos
Identificar posibles anomalias de Insercin, Borrado, y Actualizacin en una Relacin Poner una relacin en la forma normal BCNF Comprender la importancia de la forma normal Dominio/Llave (DK) Identificar dependencias multivaluadas Poner una relacin en su 4ta forma normal
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall 3-3
Chapter Premise
We have received one or more tables of existing data The data is to be stored in a new database QUESTION: Should the data be stored as received, or should it be transformed for storage?
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-4
Should we store these two tables as they are, or should we combine them into one table in our new database?
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall 3-5
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-6
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-7
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-8
Entity - Entidad
An entity is some identifiable thing that users want to track:
Customers Computers Sales
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-9
Relation - Relacin
Relational DBMS products store data about entities in relations, which are a special type of table A relation is a two-dimensional table that has the following characteristics:
Rows contain data about an entity Columns contain data about attributes of the entity All entries in a column are of the same kind Each column has a unique name Cells of the table hold a single value The order of the columns is unimportant The order of the rows is unimportant No two rows may be identical
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-10
A Relation
EMPLOYEE
La relacin Employee cumple con todas las caractersticas que definen una relacion
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-11
Relation - Relacin
Una relacin es un caso especial de una tabla Todas las relaciones son tablas, pero no todas las tablas son relaciones
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-12
No caer en la trampa de pensar que dado que una celda debe tener valor nico Significa que todos los valores deben tener la misma longitud, al contrario, la relacion mostrada tiene en la columna Comment un solo comentario por celda aunque de longitud diferente entre s.
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-13
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-14
Tables That Are Not Relations: Table with Required Row Order
Las entradas de Caruthers y Bandalone requieren un arreglo particular de renglones, si se reacomodan los renglones se sabra con precisin a quien corresponden los nmeros de fax y home
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall 3-15
Relation - Relacin
Columnas en diferentes relaciones podran tener el mismo nombre, en ejemplos previos hemos visto que dos relaciones contienen una columna con el mismo nombre: SKU. Para evitar confusiones se antepone al nombre de una columna el nombre de la relacin seguida por un punto: SKU_DATA.SKU
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-16
Alternative Terminology
Although not all tables are relations, the terms table and relation are normally used interchangeably The following sets of terms are equivalent:
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-17
Functional Dependency
A functional dependency occurs when the value of one (a set of) attribute(s) determines the value of a second (set of) attribute(s):
Functional Dependency
Functional dependencies may be based on equations: ExtendedPrice = Quantity X UnitPrice ExtendedPrice es funcionalmente dependiente de Quantity y de UnitPrice (Quantity, UnitPrice) ExtendedPrice
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall 3-20
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
Functional Dependency
La nica razn para tener RELACIONES es guardar instancias de dependencias funcionales No existe una frmula para que a partir de tu matricula de estudiante se determine Nombre, Apellidos, Promedio
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-22
Composite Determinants
Composite determinant: A determinant of a functional dependency that consists of more than one attribute
(StudentName, ClassName) (Grade)
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-23
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-24
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-25
Buyer determina Department porque Jerry Martin se apareja con un mismo departamento siempre, al igual que Cindi Lo y otros buyers. por tanto Buyer Department No ocurre as si tomamos Department para determinar un nico Buyer, pues un departamento puede tener ms de un Buyer Notar que Buyer no determina valores nicos de SKU ni SKU_Description
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall 3-26
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-27
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-28
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-29
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-30
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-32
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-33
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-34
What Makes Determinant Values Unique? A determinant is unique in a relation if, and only if, it determines every other column in the relation You cannot find the determinants of all functional dependencies simply by looking for unique values in one column:
Data set limitations Must be logically a determinant
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall 3-35
Determinantes nicos
Cada vez que un valor de la columna A parece coincidir con el mismo valor de la columna B, A puede ser determinante de B Una muestra de datos puede ser incompleta para hacer diicha afirmacin Pensar siempre en la naturaleza del negocio y en preguntar al usuario
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall 3-36
Keys
A key is a combination of one or more columns that is used to identify rows in a relation A composite key is a key that consists of two or more columns
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-37
Surrogate Keys
A surrogate key as an artificial column added to a relation to serve as a primary key:
DBMS supplied Short, numeric and never changes an ideal primary key! Has artificial values that are meaningless to users Normally hidden in forms and reports
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall 3-39
Surrogate Keys
NOTE: The primary key of the relation is underlined below:
Foreign Keys
A foreign key is the primary key of one relation that is placed in another relation to form a link between the relations:
A foreign key can be a single column or a composite key The term refers to the fact that key values are foreign to the relation in which they appear as foreign key values
3-41
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
Foreign Keys
NOTE: The primary keys of the relations are underlined and any foreign keys are in italics in the relations below:
DEPARTMENT (DepartmentName, BudgetCode, ManagerName) EMPLOYEE (EmployeeNumber, EmployeeName, DepartmentName)
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-42
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-43
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-44
Modification Anomalies
Deletion Anomaly Insertion Anomaly Update Anomaly
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-45
Modification Anomalies
The EQUIPMENT_REPAIR table before and after an incorrect update operation on AcquisitionCost for Type = Drill Press:
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-46
Normal Forms
Relations are categorized as a normal form based on which modification anomalies or other problems that they are subject to:
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-47
Normal Forms
1NF A table that qualifies as a relation is in 1NF 2NF A relation is in 2NF if all of its nonkey attributes are dependent on all of the primary key 3NF A relation is in 3NF if it is in 2NF and has no determinants except the primary key Boyce-Codd Normal Form (BCNF) A relation is in BCNF if every determinant is a candidate key I swear to construct my tables so that all nonkey columns are dependent on the key, the whole key and nothing but the key, so help me Codd.
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall 3-48
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-49
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-50
ITEM (ItemNumber, Type, AcquisitionCost) REPAIR (ItemNumber, RepairNumber, RepairDate, RepairAmount) Where REPAIR.ItemNumber must exist in ITEM.ItemNumber
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-51
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-52
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-53
SKU_DATA (SKU, SKU_Description, Buyer) BUYER (Buyer, Department) Where BUYER.Buyer must exist in SKU_DATA.Buyer
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-54
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-55
Multivaled Dependencies
A multivaled dependency occurs when a determinant determines a particular set of values:
Employee Degree Employee Sibling PartKit Part
Multivaled Dependencies
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-57
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-58
DAVID M. KROENKES DATABASE PROCESSING, 10th Edition 2006 Pearson Prentice Hall
3-59