Restructure databse