Partial Dependency in DBMS
Partial dependency is a situation in database normalization where a non-prime attribute is functionally dependent on only a part of a candidate key. The second normal form (2NF) is a normalization process that specifically addresses and eliminates partial dependencies.
What is Partial Dependency in DBMS?
To understand partial dependency, let us first know some basic terminologies with the help of an example.
Consider a relation(table) having four attributes, , , , having the following dependencies:
Using and , we can derive , and using only , we can derive . Hence, we can say that if we use both and together, then we can derive all the attributes of the table, i.e., , , , . (since and is self-explanatory).
We can write as , or in simple words, we can say the closure of and gives us all the attributes of the relation. The minimal sets like Q in a relation(table) that are capable of deriving all the attributes of a relation(table) are called . There can be more than one candidate key in a table.
If an attribute is a part of any candidate key of the relation, then it is called a else, it is said to be a . In the example above, we can say that and are primary attributes, and and are non-primary attributes.
We now know the basic definitions required to understand the concept of partial dependency. In the above example, is dependent on all the primary attributes, i.e., and . If either or are missing, then we cannot derive . In the case of , it is not the same.
Even if , a primary attribute, is missing, we can still derive using only . Hence, instead of depending totally on the candidate key, is partially dependent on , part of a candidate key. This is the concept of partial\ dependency.
What Causes Partial Dependency to Occur?
As we saw in the above section, partial dependency occurs whenever a non-prime attribute depends functionally on a part of the given candidate key.
In other words, Partial Dependency occurs when an attribute in a table depends on only a part of the primary key and not the whole key.
Partial Functional Dependency
A functional dependency denoted as where and are an attribute set of a relation, is a partial dependency , if some attribute can be removed and the dependency still holds.
Let us take an example, consider an example of a College. A student studies in a course, and every student in the college has a unique Roll number.
Course | Roll. No. | Name |
---|---|---|
BTech EE | 2015EE42 | Saloni |
BTech CS | 2014CS12 | Anshuman |
BSc Maths | 2017MM16 | Saloni |
BTech CS | 2014CS10 | Abhimanyu |
Mtech EE | 2018EE40 | Suchandra |
MTech CS | 2020CS37 | Satbir |
Suppose you are a student at this college. If a professor asks you to go and give a notebook to the student who has a roll. No. 2020CS37, you can quickly identify the student by observing his/her roll. no., i.e., . S/he is from batch, studying and his Roll. No. is .
Hence, you can successfully give him/her the notebook. You don't even need to know the Course that s/he is pursuing because you can easily determine it with his/her unique Roll. No.
In other words, if someone provides you with a just the roll number, you can quickly tell the student's name. A roll number alone is sufficient to identify or know the student's name. The attribute is partially dependent on the attribute.
Full Functional Dependency
A functional dependency denoted as where and are an attribute set of a relation, is a full dependency , if all the attributes present in are required to maintain the dependency.
Let us take an example, consider an example of a school. A student studies in a class, and in each class, every student has a unique Roll number.
Class | Roll. No. | Name |
---|---|---|
5 | 42 | Saloni |
8 | 12 | Anshuman |
11 | 37 | Saloni |
8 | 10 | Abhimanyu |
10 | 40 | Suchandra |
3 | 37 | Satbir |
Suppose you are a student at this school. If a teacher asks you to go and give a notebook to the student who has a roll. No. 37, you will get confused. Then you will ask the teacher to tell you about the class in which s/he is studying. You can then quickly identify the student and successfully give him/her the notebook.
In other words, if someone provides you with a class and the roll number, you can quickly tell the student's name. A class or a roll number alone is insufficient to identify or know the student's name. The attribute is fully dependent on the and attribute.
Conclusion
- Partial Functional Dependency occurs when an attribute in a table depends only on a part of the candidat key and not on the whole key i.e.,
- If a relation is not partially dependent then it is considered as Full Functional Dependency.