sql with changes on the structure for this branch