redoing thread table, adding foreign keys