Sunday, December 4, 2022

functional dependency, full functional dependency, partial functional dependency

Functional dependency is a constraint applied on a relation in which user can able to access values of all attributes of relation by giving value of a single attribute. it means "We can access record / row / tuple of a relation with the help of only one special attribute (key)"

Let R[A] is a relational schema. 
Here A is a set of attributes present in relation R and x,y are subset of A. 
We can say that y depends on x. 
If set of all YA then T1,T2єR such that

T1[x] = T2[x] => T1[y] = T2[y]

It shows that if two or more tuple's have same value in column x then they also have same value in column y. Thus y column depends on x column. 
We can understand functional dependency with the help of following table-



Here,   T1[A]=T2[A] => T1[C] = T2[C]
thus,  A→C

In above relation values of attribute C depend on values of attribute A but converse is not true (C→A)

There are three types of functional dependency-

(1) full functional dependency-  If relation R has a functional dependency A→B then attribute B is called full functional dependent on attribute A, if there is no Subset cєA exist for which c→B it means value of B only depend on values of A attribute.
Example-  If  all the non-key attributes depend on Primary key of table then this type of functional dependency is called full functional dependency. Similarly in account table all the non-key attributes depend on account number primary key. 

(2) partial functional dependency- If relation R has a functional dependency A→B than B is called partial functional dependent on attribute A if there is Subset cєA exist for which C→B  It means values of  attribute B can be determined by any proper subset of A. 
for example we have a relation R(A,B,C,D) where AC is primary key  AC→B, AC→D, but A→B Here A is alone capable of determining B which means B is partially dependent on AC.

Ex-  









In above table (Roll-no,Name) is a primary key then Roll-no, Name → course, Roll-no→ course, and Name→ course Thus course is partially dependent on primary key (Roll-no, name).

(3) Transitive functional dependency-
If a relation R has two or more non-key attributes which are functionally dependent and satisfy following condition 
A→B, B→C=> A→C for R(A, B, C)

Then C attribute is transitively dependent on attribute A.
To understand transitive functional dependency consider following table:-



In above table transitive functional dependency is
D_name →city, city → State => D_name → State.

Conclusion :-
functional dependency is very important for relational model.so it is neccessary that all the non-key attributes must be dependent on key attribute. it means "a relation which shows full functional dependency is free from anomalies but if a relation has partial functional dependency or transitive functional dependency or both then it affects operations of database. It Shows bad anomalies which affects Data Storing, data accessing, data manipulation and applying constraint etc operations of database. Due to which database performance decreases. In addition database with anomalies will generate incorrect result and give slow response against query. Hence, Normalisation is used to remove anomalies like Partial functional dependency, transitive functional dependency and others from the database.




No comments:

Post a Comment

Nested SQL Query or SQL Sub Query in hindi in english

if a SQL query is used inside another SQL query then this type of SQL query is called sub-query.  यदि किसी SQL क्वेरी का उपयोग, किसी अन्य SQ...