问题
I have seen many examples about fully functional dependencies, but they use to say that:
x->y such that y shouldn't be determined by any proper subset of x, x has to be a key.
But, what if y is determined by an attribute other than the proper subset or subset of x.
Suppose that I have a students table which consists of rollno(primary key), name, phone no unique not null, email unique not null.
As rollno is a primary key, let it be x and take name as y.
now x->y, but phone or email also determine y(name) which are not subsets of x. Is this still called a fully functional dependent?
If yes, should we check the determinants of y which are only subsets of x?
If no, what is the mistake I did?
回答1:
x->y such that y shouldn't be determined by any proper subset of x, x has to be a key.
You are confusing the definition of "full functional dependency" with the definition of "2NF". The definition of fully functionally dependent has nothing to do with superkeys or candidate keys or primary keys. And for a relation to be in 2NF, if X is a candidate key and Y is non-prime then Y can't be determined by any proper subset of X.
A functional dependency X -> Y is partial when Y is also functionally dependent on a proper/smaller subset of X. Otherwise it is full. It doesn't matter what else is true.
A superkey is a column or set of columns that functionally determines every column. If there is no smaller superkey inside it then it is a candidate key. A relation is in 2NF when every attribute is fully functionally dependent on every candidate key. It doesn't matter what else is true.
You can pick one candidate key to call primary key. So a primary key is a candidate key. Otherwise the notion of "primary key" is irrelevant to functional dependencies and normalization.
(In SQL primary key
means the same as unique not null
, namely superkey. Which is a candidate key only if there's no smaller superkey in it. So a set declared primary key
might not even be a primary key. And in SQL you can't declare {} as a superkey.)
As rollno is a primary key, let it be x and take name as y.
A primary key is a candidate key, so {rollno
} determines every attribute and no proper subset of {rollno
} determines every attribute. So {}, the only proper subset of {rollno
}, is not a superkey. ({} is a superkey when there can only ever be at most one row in the table.) But it's still possible that {} -> name
. (That would be if the name
column only contains at most one name at a time.) Then {rollno
} -> name
would be partial because its proper subset {} determines name
.
now x->y, but phone or email also determine y(name) which are not subsets of x. Is this still called a fully functional dependent?
If no proper subset of {rollno
} determines name
then {rollno
} -> name
fully, otherwise partially. That's what the definition says. Nothing else matters. But we don't know whether proper subset of {rollno
} determines name
because you didn't say whether {} -> name
.
If {rollno
}, {phoneno
} and {email
} are candidate keys and {} doesn't determine name
then name
is fully functionally dependent on all three (because no proper subset of any of them determines name
).
回答2:
You are saying:
x->y such that y shouldn't be determined by any proper subset of x, x has to be a key.
but this mixes two different concepts, that of “full functional dependency”, and that of “key”.
A functional dependency is full if you cannot remove any element of the left part without losing the propoerty of determining the right part. So if a functional dependency has only one attribute on the left part (like rollno → name
), it is always complete.
A (candidate) key on the other hand is a set of attributes that determines all the attributes of a relation, and such that you cannot remove any attribute from it without losing the property of being a key (so, it is not a superkey).
In your example there are three different keys, rollno
, phone
, and email
, each of them composed by a single attribute.
Of course, if you know that the set of attributes X
is a key, you can write that X → T
, where T
are all the attributes of the relation, and this functional dependency is complete.
来源:https://stackoverflow.com/questions/35943103/is-an-fdfunctional-dependency-fully-fd-when-x-y-and-z-y-where-z-is-not-a-sub