Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialaroshinemunasinghe
5,649 PointsFunctional Dependency - help
I know there are no course in database called functional dependency which is SAD. So I wonder if you know about functional dependency? please look at this link: https://i.stack.imgur.com/3QD7I.png
and I have got answer:
costumer -> city
costumer -> population
price -> product
price -> costumer
price -> city
price -> population
city -> population
population -> city
but actually the answer is:
(product, costumer) -> price
costumer -> city
city -> population
costumer -> population
:sad: what did I do wrong?!
1 Answer
Kevin D
8,646 PointsThis is a really late answer...but can you also provide an updated image link?
I don't know if this will help you or not, but what I understand from functional dependencies is that the element on the left side of the arrow (leftSideElement -> rightSideElement) is only allowed to be mapped to one unique element on the right side in order to evaluate to true. If that element maps to two different elements, then it evaluates to false. However, two different elements are also allowed to be mapped to the same element (evaluating to true also).
Confused?
I'll try to give an example:
Imagine there are 4 tables called A, B, C and D that list their elements in a single column (Img of what I'm talking about: http://imgur.com/a/GJJSW). A contains the elements a1, a1, a2, a2 B contains the elements b2, b2, b3, b4 C contains the elements c1, c1, c2, c3 D contains the elements d1, d1, d1, d4
If we say A->B, the answer will be false because: a1 -> b2 (a1 works because A1 maps to a unique element) a1 -> b2 a2 -> b3 (a2 doesn't, because it's mapping to 2 different elements) a2 -> b4
If we say C->D, the answer would be true because: c1 -> d1 (c1 works because it is mapping to a unique element) c1 -> d1 c2 -> d1 (c2 also works even though c1 maps to d1 too!) c3 ->d4 (c3 is mapping to d4 and nothing else)
I hope that helps!