This is the second part of the CUBRID it! contest overview. We've already covered the first part, where we focused on the contest problem itself, its possible solutions, and important details participants had to pay attention to. We highly recommend to read the first part of this blog before reading further.

In this second part we will look into some of the most interesting code and approaches we have received from you. We hope you can learn something new from solutions submitted by other users.

Getting the results

Excluding unwanted columns by filtering on data types

Besides the obvious data types we want to exclude – like INTEGER-ones, maybe the most challenging one is NUMERIC, because it requires an extra analysis of the scale (the number of digits after the decimal point) value, for example:

Please note that because the most expensive tasks are still the database queries, these various approaches shouldn’t make a great difference in terms of execution time. However, you should still try to optimize an approach like this one, where a lot of iterations are being done for every value:

As we have mentioned before, most of the solutions implemented a client-side approach. For example – see the comment below:

/**
* For each table in the list, selects everything in them and puts them in a HashMap
* If it does not exist (i.e. resultsMap.containsKey == false), it's added, else, it's incremented
* On-the-fly, it determines the maximum occurrence number, by checking it agains a variable (that is initially 0)
* The main idea is actually based around the efficiency of the Java HashMap class.
* The keys are the query results, while the values are their occurrences.
*/