sql creation script mostly done, needs testing