Rules of Functional Dependencies
Rules of Functional Dependencies
Below given are the Three most important rules for Functional Dependency:
EMPLOYEE table:
The decomposition of the EMPLOYEE table into 1NF has been shown below:
EMP_ID EMP_NAME EMP_PHONE EMP_STATE
14 John 7272826385 UP
14 John 9064738238 UP
20 Harry 8574783832 Bihar
12 Sam 7390372389 Punjab
12 Sam 8589830302 Punjab
The First normal form simply says that each cell of a table should contain exactly one value.
1NF Example
Second Normal Form (2NF)
Example: Let's assume, a school can store the data of teachers and the subjects they teach. In a
school, a teacher can teach more than one subject.
TEACHER table
To convert the given table into 2NF, we decompose it into two tables:
TEACHER_DETAIL table:
TEACHER_ID TEACHER_AGE
25 30
47 35
83 38
TEACHER_SUBJECT table:
TEACHER_ID SUBJECT
25 Chemistry
25 Biology
47 English
83 Math
83 Computer
The above table is a composite one and has a composite primary key (CUSTOMER ID, STORE ID). The
non-key attribute in this arrangement is STORE LOCATION. In the above case, the STORE LOCATION only
depends on the STORE ID, which is the sole part of the primary key. Hence the table does not satisfy the
second normal form.
Fourth normal form
A table is said to be in fourth normal form if there is no two or more, independent and
multivalued data describing the relevant entity.
Candidate Key
Candidate keys are defined as the minimal set of fields which can uniquely identify each record
in a table. It is an attribute or a set of attributes that can act as a Primary Key for a table to
uniquely identify each record in that table. There can be more than one candidate key.
For example, student_id and phone both are candidate keys for table Student.
A candiate key can never be NULL or empty. And its value should be unique.
There can be more than one candidate keys for a table.
A candidate key can be a combination of more than one columns(attributes).
Composite Key
Key that consists of two or more attributes that uniquely identify any record in a table is called
Composite key. But the attributes which together form the Composite key are not a key
independently or individually.
In the above picture we have a Score table which stores the marks scored by a student in a
particular subject.
In this table student_id and subject_id together will form the primary key, hence it is a
composite key.
3NF Example