implement getting keys from tables in mysql/postgres