SQL to generate DB