in reply to Re^2: Finding Keys from data
in thread Finding Keys from data

My reason to do it backwards was because I thought that checking for whether a key could be removed or not was easier than checking if a key should be added. Because in the first case you only have to check whether one key is duplicate now (easy to do with a hash. In the second case you have to check whether the addition of the key improves anything.

This is a big problem with your solution now. Say two columns have the same values, but with many different values so they are both high on the @colOrder list. They will both be added even though only one of them would improve the key quality, the other is completely useless.

You also talk about an improvement by removing "duplicate" rows. Did you mean "singular" rows? I.e. a row that is already singled out/identified completely by the key isn't important anymore for finding relevant keys and could be removed. This is one possible way to check for whether a key improves things.

One factor that also should be taking into account, if you want to determine whether adding or removing is better, is how many keys the solution likely needs. If the data is nearly as random as BrowserUKs test data, obviously the solution will only need a few columns. But if many columns are linked to each other and have only a few different values, the key needs many columns

Though the more columns the key needs the worse it is as a key ;-). A key that needs 50 of the 100 columns already uses half the space of the database itself

Replies are listed 'Best First'.
Re^4: Finding Keys from data
by roboticus (Chancellor) on Apr 01, 2011 at 12:12 UTC

    jethro:

    Yes, I meant singular rows.

    Now that you mention it, I see your point regarding trying to remove columns rather than add them. I'd try to add the refinement I mentioned earlier, but I suspect that it wouldn't give anything significantly better than what you've described.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

    Update: Rephrased a bit.