Search code examples
databaserelational-databaseone-to-manyfunctional-dependencies

Functional dependency vs one-to-many (or many-to-many ) relationships


I understand what
1) a FD (functional dependency) is
A --> B i.e for a value a1 in A there will be a corresponding unique value b1 in B.
2) and in a one-to-many relationship,
for a value a1 in A there will be one or more corresponding values i.e. b1 or b1, b2, b3 etc in B. My question is on one-to-may part.
Q1) Is there any other name for this relationship in normalization terminology. ( MVD can come in to picture, but can ignore it for a while as I am speaking about one set of data only unless the rest is considered null. )

Q2) is a one-to-many relationship a FD (or is it a MVD - just clarifying, but otherwise ignore this) ?? It might look crazy to ask this. But there is definitely lot of relationship here between A and B as the values of B are still determined by A and this come from the problem domain (which is in other words ... functional world). Ex -A student still determines what courses he want to enroll. He might still have the freedom to enroll for 5 or 7 course which is only the cardinality. But it is still the student and only student who determines the course ( and how many of them.) Or in other words - a one-to-many says about "cardinality" but what about the relationship itself. CALL IT WHAT? (can it still be called functional or some thing else which speaks about what is determining the rest)


Solution

  • A Functional Dependency A → B in a relation R (A, B, C, ...) is a constraint satisfied by the instances of R (that is any set of tuples of R) in which, every time there are two or more tuples with the same value of the attribute A, then all of them have the same value of the attribute B (note that A and B can also be set of attributes) (the “valid” instances of R).

    Since you cannot have different values of B for a certain value of A, this situation is called a “functional dependency”, and the “meaning” is that you are modeling a world in which a certain value is uniquely determined by another (for instance, given the SSN of a person, you have a unique birthdate).

    While in modelling certain situations you can say that a set of values of an attributes is uniquely determined by another (for instance, given the SSN of a person, you have a unique set of skills), there is no “equivalent” constraint in the normalization theory, and this for the reason that an attribute of a relation can have only an elementary value, not a set of values. So, if you have modelled this situation with a relation with attributes SSN and Skill, you need to put in an instance multiples rows with the same SSN and different skills to represent all the skills of a single person.

    What you can have, instead, in the normalization theory, is another constraint, called Multivalued Dependency, that is significant only when you have, in the same relation, at the same time, multiple situations like that of the example above. For instance, if you have a relation like Employees(SSN, Skill, Child), if a certain employee has n skills and m children, you should represent this information with n x m rows for that employee, m rows with all the children for a each skill, and symmetrically n rows with all the skills for a each child. In this case, we can say that an instance is valid if it satisfies the couple of MVDs SSN →→ Skill and SSN →→ Child, or, equivalently, the Binary Join Dependency Employees = SSN Skill ⨝ SSN Child. And this is equivalent to say that the relation can be safely1 decomposed in two relations, E1(SSN, Skill), E2(SSN, Child).

    1 I.e., without loss of information.