I\'m taking a database theory course, and it\'s not clear to me after doing the reading how I can infer keys, given a set of functional dependencies.
I have an examp
If code talks to you more than long explanations, here is a 25 lines implementation of an algorithm that finds keys based on functional dependencies:
https://github.com/lovasoa/find-candidate-keys/blob/master/find-candidate-keys.js
candidate_keys(["A","B","C","D","E","F","G"], [
[['A','B'], 'C'],
[['C','D'], 'E'],
[['E','F'], 'G'],
[['F','G'], 'E'],
[['D','E'], 'C'],
[['B','C'], 'A']
])
returns
[["B","D","F","G"],["B","D","E","F"],["B","C","D","F"],["A","B","D","F"]]