给定一组通用属性和功能依赖性列表,确定所有候选键

时间:2016-08-29 21:40:39

标签: java database algorithm normalization candidate-key

现在我在java中实现了以下算法,用于确定所有可能正常工作的候选键。链接如下: -

http://shubhamshoundic.blogspot.com/2012/08/an-algorithm-to-find-all-possible.html

但是在最坏的情况下,即,如果FD的两侧都存在所有属性(如上面链接中定义的情况M),可以处理的FD的数量减少到12或13 < / em>。

原因是java中的堆空间有限。抛出以下错误: -

OutOfMemoryError

我的要求是帮助我实现这样的算法,它将具有更简单的复杂性(现在是指数),以便将处理的FD数量提高到至少20

我应该尝试使用多处理来计算它,还是应该转换到另一种语言而不是java。

1 个答案:

答案 0 :(得分:1)

It is known from 1978, and presented in all good books on databases, that the problem of finding all the keys requires an algorithm which has an exponential complexity in the worst case (see for instance: Lucchesi, C. and Osborn, S. (1978). Candidate keys for relations. Journal of Computer and System Sciences, 17(2):270–280). Moreover, the problem of finding if an attribute is prime is NP Complete.

This is due to the fact that the number of possible keys is itself exponential with the number of attributes or factorial with the number of functional dependencies.

So, it is impossible to find an algorithm polynomial with the number of attributes or of the functional dependencies.