Adjusted SQL structure