rewrite database and restruct.