Refactor database sample to be able to create table correctly