![]() |
VOOZH | about |
Databases are structured to handle cases where some data relies on only part of a key, not the whole key. In this case we can say data is partially dependent. Partial dependency is similar to a functional or strong dependency, as it shows a constrained relationship between two or more attributes in a table.
Key terms to know before we learn more about partial dependency:
In a database, a partial dependency occurs when a non-key column (i.e., not part of any candidate key) depends on only part of a composite primary key instead of the full key. This is explained in detail with the help of below given example.
Student_ID | Course_ID | Course_Name | Instructor |
|---|---|---|---|
1 | 101 | Math | Mr. Smith |
1 | 102 | Science | Ms. Johnson |
2 | 101 | Math | Mr. Smith |
3 | 103 | English | Mr. Brown |
Explanation:
To resolve this dependency we will use normalization. For normalizing this table we will split it into two tables:
1. Student_Course:
Student_ID | Course_ID | Instructor |
|---|---|---|
1 | 101 | Mr. Smith |
1 | 102 | Ms. Johnson |
2 | 101 | Mr. Smith |
3 | 103 | Mr. Brown |
2. Course:
Course_ID | Course_Name |
|---|---|
101 | Math |
102 | Science |
103 | English |
Partial dependency can be identified by testing the functional dependencies between the attributes in a table. Functional dependencies describe how one or more attributes rely on another attribute, which may be within the same table or across different tables. In the case of partial dependency, an attribute depends only on part of the primary key.
If Course_Name is only dependent on Course_ID (the primary key), then Course_Name is partially dependent on the primary key.
One way to detect partial dependency is by scanning the table for similar or repeated data. This can be tricky when the data isnβt clearly organized. Repeated data can lead to inconsistencies and discrepancies, which might not be obvious without examining the table for patterns of data duplication.
Normalization of tables holds the key to eliminating potential dependencies among attribute elements. Normalization is a process aimed at refining a database to reduce redundancy and ensure data consistency.
There are different levels of normalization, each with its own set of rules and requirements:
Beyond the third normal form, there are higher levels of normalization, such as Fourth Normal Form (4NF) and Fifth Normal Form (5NF). However, these forms are rarely used in practice.
Original Table (CourseEnrollment):
StudentID | CourseID | CourseName | Instructor | Department |
|---|---|---|---|---|
1001 | CS101 | Introduction to Computer Science | Dr. Lee | Computer Science |
1001 | Math202 | Calculus II | Dr. Miller | Mathematics |
1002 | HIS101 | World History | Dr. Khan | History |
1002 | ENG205 | Literature | Prof. Jackson | English |
1003 | CS202 | Data Structures | Dr. Lee | Computer Science |
Here the department is partially dependent on the instructor. While an instructor typically teaches courses in his or her own department, an instructor may also teach courses from other departments. This creates a partial dependency. We will use normalization to reduce partial dependency.
Decompose the table into two separate tables:
Course Enrollment:
StudentID | CourseID | CourseName | Instructor |
|---|---|---|---|
1001 | CS101 | Introduction to Computer Science | Dr. Lee |
1001 | Math202 | Calculus II | Dr. Miller |
1002 | HIS101 | World History | Dr. Khan |
1002 | ENG205 | Literature | Prof. Jackson |
1003 | CS202 | Data Structures | Dr. Lee |
InstructorDepartment:
Instructor | Department |
|---|---|
Dr. Lee | Computer Science |
Dr. Miller | Mathematics |
Dr. Khan | History |
Prof. Jackson | English |
Dr. Lee | Computer Science |