refactor database and tupleBase creation