create table logic