80 likes | 210 Views
CSC 1035 Supplement for Chapter 2 Functional Dependencies. Definition and Notation. Suppose X and Y are sets of attributes (column names) Check whether this statement is true or not: “For every set of values in the X columns, there can be at most one set of values in the Y columns”
E N D
CSC 1035 Supplement for Chapter 2 Functional Dependencies
Definition and Notation • Suppose X and Y are sets of attributes (column names) • Check whether this statement is true or not: “For every set of values in the X columns, there can be at most one set of values in the Y columns” • If that’s true, then say X determines Y • And write X -> Y
An example of some FD’s • Suppose the attribute names are: • stuId, firstName, lastName, major, credits, classNumber, grade, schedule, room, facId, name, rank, department • And suppose the semantics are the same as in University.mdb • On the next pages, let’s analyze those attributes for FD’s.
Examples from University.mdb • This statement is true: “For every set of values of stuId, classNumber, there can be at most one grade.” • So is this one: “For every value of stuId, there can be at most one value of firstName and lastName. • This one isn’t true: “For every value of classNumber, there can be at most one value of stuId.”
Examples, continued • Phrasing the examples from the previous slide in technical database language: • stuId, classNumber -> grade • stuID -> firstName, lastName • classNumber does NOT determine stuId
Here’s a complete list of FD’s • stuId -> firstName, lastName, major, credits • stuId, classNumber -> grade • classNumber -> room, schedule, facId • facId -> name, rank, department
Setting up the tables in the database • Each of the FD’s in the last slide should lead to its own table. • Within each table, the left-hand part of the FD becomes the primary key. • So rather than a single table with all 13 attributes, we get four tables, each with fewer attributes. • The big table would have had redundancies.
Normalization • The process of decomposing a big table into smaller ones, in order to avoid redundancies and anomalies, is called normalization. • An indication of a table that’s not normalized would be if you can spot a FD X->Y where X isn’t a key for that table.