Sunteți pe pagina 1din 9

Database Management Systems Relations A named, two-dimensional table or data.

. It consist of a set of named columns and an arbitrary number of named rows.

Properties:
1. Entries in columns are atomic (or single-valued). 2. Entries in columns are from the same domain. 3. Each row is unique (no duplicate rows). 4. The sequence of columns (left to right) is insignificant. 5. The sequence of columns (top to bottom) is insignificant.

Entries in columns are atomic (or single-valued) PATIENT patientNo name dateVisit physician symptoms

987 988

John Miranda

02/26/06 02/27/06 02/26/06

Dr. Smith Dr. Alvarez Dr. Hope

Nervousness Panicky Depression

To correct the relation: PATIENT patientNo name dateVisit physician symptoms Make separate rows.

987 987 988

John John Miranda

02/26/06 02/27/06 02/26/06

Dr. Smith Dr. Alvarez Dr. Hope

Nervousness Panicky Depression

Entries in columns are from the same domain

AARGV

PATIENT patientNo name dateVisit physician symptoms

987 987 988


John John Miranda

02/26/06 02/27/06 02/26/06

Dr. Smith Dr. Alvarez Dr. Hope

Nervousness Panicky Depression

patientNo : 3 Digits ONLY dateVisit : Only date entries allowed

Each row is unique (no duplicate rows) Primary key - is an attribute that uniquely identifies the instance row. PATIENT patientNo name dateVisit physician symptoms

u n i q u
e

987 987 988

John John Miranda

02/26/06 02/27/06 02/26/06

Dr. Smith Dr. Alvarez Dr. Hope

Nervousness Panicky Depression

The sequence of columns (left to right) is insignificant PATIENT patientNo dateVisit name symptoms physician

987 987 988

02/26/06 02/27/06 02/26/06

John John Miranda

Nervousness Panicky Depression

Dr. Smith Dr. Alvarez Dr. Hope

The sequence of columns (top to bottom) is insignificant. PATIENT patientNo name dateVisit physician symptoms
AARGV

987 988 987

John Miranda John

02/26/06 02/27/06 02/26/06

Dr. Smith Dr. Hope Dr. Alvarez

Nervousness Depression Panicky

Functional Dependency Relationship between two attributes o A > B o A is determinant of B o The value of A uniquely determined the value of B o The functional dependence of B & A. Problem No. 1 Determined the functional dependency notation and primary

key of the relation.


PATIENT patientNo Name Address

0123 0124
Solution:

Ivy Goodings Janneth Virginia

Orange Country, CA San Francisco, CA

Patient: patientNo -> Name, Address


Functional Dependents

Therefore the relation is: PATIENT (patientNo, Name, Address)

Problem No. 2 Determine the functional dependency notation and primary key

of the given table.

AARGV

GRADE SHEET StudentNo SubjectCode Grade

0456 0456 0458 0458


Solution:

CS121 CS122 CS121 CS122

A+ A F C

GradeSheet: StudentNo, SubjectCode -> Grade Therefore relation is: GradeSheet: (StudentNo, SubjectCode, Grade) Composite key primary key with more than one attribute.

Partial Functional Dependency Dependency in which one or more non-key attribute are functionally dependent on part (but not all) of the primary key. Problem No. 3 Determine the functional dependencies and primary key.

Remove the partial dependencies. Design an ERD at the end.


EMPLOYEEE EmpID Name Dept Salary Training TrainingDate

0123 0123 0124


Solution:

Ivy Goodings Ivy Goodings Janneth Virginia

EDP EDP Helpdesk

30,000 30,000 20,000

Javascript C# MySQL

3/1/2010 3/5/2010 3/1/2010

EmpID -> Name, Dept, Salary EmpID, Training, TrainingDate

PFD
AARGV

Therefore the relation is: EMPLOYEE (EmpID, Training, Name, Dept, Salary, TrainingDate) To remove partial dependency, split the relation into new relations according to functional dependencies. PERSONNEL: (EmpID, Name, Dept, Salary) TRAINING: (EmpID, Training, TrainingDate) SPLIT THE RELATION INTO TWO: EMPLOYEE EmpID Name Dept Salary Training TrainingDate

0123 0123 0124

Ivy Goodings Ivy Goodings Janneth Virginia

EDP EDP Helpdesk

30,000 30,000 20,000

Javascript C# MySQL

3/1/2010 3/5/2010 3/1/2010

PERSONNEL EmpID Name Dept Salary

0123 0123 0124


TRAINING EmpID

Ivy Goodings Ivy Goodings Janneth Virginia

EDP EDP Helpdesk

30,000 30,000 20,000

Training

TrainingDate

0123 0123 0124

Javascript C# MySQL

3/1/2010 3/5/2010 3/1/2010

AARGV

ERD will be: (EmpID, Name, Dept, Salary)

MAXIMUM (EmpID, Training, TrainingDate)

Personnel

0 MAXIMUM

Training

CORDINALITY CONSTRAINTS Specifies the number of instances of one entity that can (or must) be associated with each instance of another entity.

Why remove partial dependency? EMPLOYEE EmpID Name Dept Salary Training TrainingDate

0123 0123 0124

Ivy G. Ivy G. Janneth V.

EDP EDP Helpdesk

30,000 30,000 20,000

Javascript C# MySQL

3/1/2010 3/5/2010 3/1/2010

There is Anomalies:
AARGV

Modifications How many times do we need to update Ivys record is she intends to transfer at business intelligence dept? Insertion If new employee is entered, you are forced to put an entity on training BECAUSE it is part of primary key. Deletion if Janneth is deleted, do we need to delete all the training she took.

Transitive Dependency A function dependency between two or more non-key attributes in a relationship. Problem No. 4 Determine the functional dependencies and primary key.

Remove functional and tentative dependencies. Design an ERD at the end.


EMPLOYEE EmpID Name Gender BranchCode BranchName

Emp01 Emp02 Emp03


Solution:

Tom Parson Anne Wells Icee Almonds

M F F

BR01 BR02 BR01

Manila Cebu Manila

EmpID -> Name, Gender, BranchCode, BranchName BranchCode -> BranchName

Non-key Attribute

Transitive dependent

Therefore the relation is:


AARGV

EMPLOYEE (EmpID, Name, Gender, BranchCode, BranchName) The other partial functional dependent or transitive dependents from the given relation?

BranchName is transitive dependent.


To remove transitive dependent, split the relations. PERSONNEL: (EmpID, Name, Gender, BranchCode) BRANCH: (BranchCode, BranchName) IMPLEMENTING THE SPLIT UP WOULD MEAN: EMPLOYEE EmpID Name Gender BranchCode BranchName

Emp01 Emp02 Emp03


PERSONNEL EmpID

Tom Parson Anne Wells Icee Almonds

M F F

BR01 BR02 BR01

Manila Cebu Manila

Name

Gender

BranchCode

Emp01 Emp02 Emp03


BRANCH

Tom Parson Anne Wells Icee Almonds

M F F

BR01 BR02 BR01

BranchCode

BranchName

BR01 BR02 BR01

Manila Cebu Manila


AARGV

Foreign Key is an attribute that appears as a non-key attributes in the relation and as a primary key in another relation.

To Design the ERD: EmpID, Name, Gender, BranchCode

Personnel

Branch

(BranchCode, BranchName)

AARGV

S-ar putea să vă placă și