|
Company(SSN, fname, ..., DNo, DName, ..., PNo, PName, ..., DepName,..) |
This relation (containing every attribute is called the universal relation
Name | Course | Course Name | Semester | Grade |
---|---|---|---|---|
James Bond | CS170 | Intro to CS | Fall 1997 | B- |
James Bond | CS255 | Assembler programming | Fall 1998 | B+ |
James Bond | CS355 | Computer Architecture | Spring 1999 | C+ |
John Doe | CS170 | Intro to CS | Spring 2000 | A- |
John Doe | CS255 | Assembler programming | Fall 2001 | C+ |
John Doe | CS355 | Computer Architecture | Spring 2002 | D+ |
See: click here
I gave you the following reason why the relation was bad:
|
|
|
Employee (SSN, FName, LName, BDate, DNum, DName, MgrSSN) |
SSN | FName | LName | BDate | DNum | DName | MgrSSN |
---|---|---|---|---|---|---|
111-11-1111 | John | Smith | Jan-1-78 | 5 | Research | 123-45-6789 |
222-22-2222 | Jane | Doe | Apr-1-76 | 5 | Research | 123-45-6789 |
333-33-3333 | Jack | Rabbit | May-4-79 | 1 | Payroll | 777-77-7777 |
These tuples represent the following information:
|
dnumber=6, dname='Human Resources' |
that does not have any employees yet, then:
|
Example:
SSN | FName | LName | BDate | DNum | DName | MgrSSN |
---|---|---|---|---|---|---|
111-11-1111 | John | Smith | Jan-1-78 | 5 | Research | 123-45-6789 |
222-22-2222 | Jane | Doe | Apr-1-76 | 5 | Research | 123-45-6789 |
333-33-3333 | Jack | Rabbit | May-4-79 | 1 | Payroll | 777-77-7777 |
NULL | NULL | NULL | NULL | 6 | Hum Resources | NULL |
Consider:
SSN | FName | LName | BDate | DNum | DName | MgrSSN |
---|---|---|---|---|---|---|
111-11-1111 | John | Smith | Jan-1-78 | 5 | Research | 123-45-6789 |
222-22-2222 | Jane | Doe | Apr-1-76 | 5 | Research | 123-45-6789 |
333-33-3333 | Jack | Rabbit | May-4-79 | 1 | Payroll | 777-77-7777 |
SSN | FName | LName | BDate | DNum | DName | MgrSSN |
---|---|---|---|---|---|---|
111-11-1111 | John | Smith | Jan-1-78 | 5 | Research | 123-45-6789 |
222-22-2222 | Jane | Doe | Apr-1-76 | 5 | Research | 123-45-6789 |
Result:
|
Here you witness the undesirable (= dangerous) behavior of the delete anomaly:
|
SSN | FName | LName | BDate | DNum | DName | MgrSSN |
---|---|---|---|---|---|---|
111-11-1111 | John | Smith | Jan-1-78 | 5 | Research | 123-45-6789 |
222-22-2222 | Jane | Doe | Apr-1-76 | 5 | Research | 123-45-6789 |
333-33-3333 | Jack | Rabbit | May-4-79 | 1 | Payroll | 777-77-7777 |
|
The correct result is the following database content:
SSN | FName | LName | BDate | DNum | DName | MgrSSN |
---|---|---|---|---|---|---|
111-11-1111 | John | Smith | Jan-1-78 | 5 | Research | 888-88-8888 |
222-22-2222 | Jane | Doe | Apr-1-76 | 5 | Research | 888-88-8888 |
333-33-3333 | Jack | Rabbit | May-4-79 | 1 | Payroll | 777-77-7777 |
Notice:
|
Consequence of an update anomaly:
|
Example:
SSN | FName | LName | BDate | DNum | DName | MgrSSN |
---|---|---|---|---|---|---|
111-11-1111 | John | Smith | Jan-1-78 | 5 | Research | 888-88-8888 |
222-22-2222 | Jane | Doe | Apr-1-76 | 5 | Research | 123-45-6789 |
333-33-3333 | Jack | Rabbit | May-4-79 | 1 | Payroll | 777-77-7777 |
Data inconsistency: the Research department now has two different managers !!!!
|
Query:
|
Method 1 provide a more efficient (= faster) way to access the information
|
|
|
We will now study in more detail why some relations are bad
More importantly:
|