fix database determination, normalize column names unconditionally to lower-case