Transcript for:
Understanding Functional Dependencies in Databases

functional dependency yes so today we are going to simplify the concept of functional dependency hello guys and welcome to my channel making it simple so when we learn about keys in database or normalization or various normal forms we come across the term functional dependency what exactly is functional dependency let us find out so without wasting any time let us start after a short intro [Music] so in mathematics you must have seen this this simply means when a is given as input to the function f it computes and generates some output b for example let that function be a square function which calculates square of a number and we provide an input 5 to it so simply by computing square of phi which is 25 it will be computed as an output somewhat similar to this function is functional dependency in database for example we have a table t having columns a and b and if we write a goes to b what does that mean like our mathematical example it doesn't mean that if we have a we can compute or generate b it is different it means that if we know the value of a we can search or find or determine the value of b from the relation or table for example if we are given the value of a as 2 can we find the value of b so we check the table and search for 2 in column a and corresponding to that 2 we get a value of b which is d e f so by using a we got or found the value of b so that means we can say that a determines b or b is determined by a and we can say that a determines b is a functional dependency so in functional dependency the attribute which is used to determine other attribute is called determinant and the attribute which is determined using the determinant is called as dependent so the definition of the functional dependency states that a functional dependency is a constraint that specifies the relationship of one attribute to another attribute in a relation or a table now let us take an example for better understanding consider this relation or a table and based on this relation let us check whether the functional dependencies are valid or invalid so for the first one let us consider this functional dependency roll number determines student name department name and department building so as a role number is considered as unique value for each student definitely by using roll number we can search or identify student name department name and department building for example if we have roll number 3 we can uniquely determine the student name department name and department building for role number three so we can confirm that it is a valid functional dependency so in a case where there are different determinants and corresponding different dependents this kind of case is a valid functional dependency next one let us consider another functional dependency department name determines department building now we can notice that department name attribute has redundant or duplicate values present in it does that mean it is an invalid functional dependency well let us check using an example there are two records for cs in department name attribute so both can be written as determinant so what are their corresponding dependent values both have a4 department building as their corresponding dependents so we write them as their dependents is this an invalid case no it is not an invalid functional dependency if i ask you look at the table and tell cs department is in which building if you check this tuple your answer will be a4 if you check this tuple still your answer will be a4 there is redundancy in data but the data present in relation is correct so this is a valid functional dependency so in a case where there are same determinants and have same dependent values it is a valid functional dependency case let's consider another case using similar functional dependency as used previously department name determined department building so department name ec determines department building b2 and department name me also determines department building b2 here in this case we have two different determinants but the corresponding dependent values are the same is this a valid functional dependency yes it is a valid functional dependency there can be two departments present in a same building let's take another example another example can be roll number determining student name where two students have different role numbers but have same name but still it is a valid case therefore this functional dependency is a valid one so in this case where there are different determinants and corresponding same dependents it is a valid functional dependency case now let us consider fourth and the last case here let us consider functional dependency student name determines department name in the student name attribute we have redundancy two students have the same name so if i ask you tell me department name of student xyz you will find two different answers for it one will be cs department and another will be it department we cannot uniquely identify the department name just by using student name therefore this functional dependency is an invalid one so in a case where there are two same determinants and they have different corresponding dependents such a case is an invalid functional dependency case so these are the four cases three of them are valid and one is invalid by checking these conditions you can determine whether functional dependency is valid one or not hope you understood the concept of functional dependency in the upcoming videos we will cover the types of functional dependencies and remaining normal forms so stay tuned if my videos help you in clearing the concept and your doubts leave a like and share the video with others in it and for more such amazing videos subscribe my channel making it simple and press the bell icon to get latest video notifications see you in the next video thank you you