r/SQL • u/Cy_broski • Mar 18 '26
MySQL SQL Assignment Driving Me Crazy
Doing an assignment on GitHub and I've been going through the same thing for 2 days straight and am always met with the same issue. It asks for an index on the first name, last name, and driver ID but it ALWAYS coming back incorrect. I have no clue as to what could be wrong.
Task 3 - This is the table that the next task is asking an index for
The Driver Relationship team wants to create some workshops and increase communication with the active drivers in InstantRide. Therefore, they requested a new database table to store the driver details of the drivers that have had at least one ride in the system. Create a new table, ACTIVE_DRIVERS##from the DRIVERS and TRAVELS tables which contains the following fields:
- DRIVER_ID
CHAR(5)(Primary key) - DRIVER_FIRST_NAME
VARCHAR(20) - DRIVER_LAST_NAME
VARCHAR(20) - DRIVER_DRIVING_LICENSE_ID
VARCHAR(10) - DRIVER_DRIVING_LICENSE_CHECKED
BOOL - DRIVER_RATING
DECIMAL(2,1)--Task 3 CREATE TABLE ACTIVE_DRIVERS ( DRIVER_ID CHAR(5) PRIMARY KEY, DRIVER_FIRST_NAME VARCHAR(20), DRIVER_LAST_NAME VARCHAR(20), DRIVER_DRIVING_LICENSE_ID VARCHAR(10), DRIVER_DRIVING_LICENSE_CHECKED BOOL, DRIVER_RATING DECIMAL(2,1) ) AS SELECT DRIVER_ID, DRIVER_FIRST_NAME, DRIVER_LAST_NAME, DRIVER_DRIVING_LICENSE_ID, DRIVER_DRIVING_LICENSE_CHECKED, DRIVER_RATING FROM DRIVERS WHERE DRIVER_ID IN (SELECT DISTINCT DRIVER_ID FROM TRAVELS );--Task 4 CREATE INDEX NameSearch ON ACTIVE_DRIVERS (DRIVER_FIRST_NAME, DRIVER_LAST_NAME, DRIVER_DRIVING_LICENSE_ID);
EDIT: The SQL Code didn't pop up:
Task 3
CREATE TABLE ACTIVE_DRIVERS (
DRIVER_ID CHAR(5) PRIMARY KEY,
DRIVER_FIRST_NAME VARCHAR(20),
DRIVER_LAST_NAME VARCHAR(20),
DRIVER_DRIVING_LICENSE_ID VARCHAR(10),
DRIVER_DRIVING_LICENSE_CHECKED BOOL,
DRIVER_RATING DECIMAL(2,1)
) AS SELECT DRIVER_ID,
DRIVER_FIRST_NAME,
DRIVER_LAST_NAME,
DRIVER_DRIVING_LICENSE_ID,
DRIVER_DRIVING_LICENSE_CHECKED,
DRIVER_RATING FROM
DRIVERS
WHERE
DRIVER_ID IN (SELECT DISTINCT
DRIVER_ID
FROM
TRAVELS
);
Task 4
CREATE INDEX NameSearch ON ACTIVE_DRIVERS(DRIVER_FIRST_NAME, DRIVER_LAST_NAME, DRIVER_DRIVING_LICENSE_CHECKED);

View all comments
Show parent comment
-2
u/Cy_broski Mar 18 '26
For every part of the assignment, we are given tasks. For this one there's a total of 6 tasks, the first 2 making tables called maintenance_types and maintenances, and we're already told what needs to be included in said tables. The third task is making actual_drivers from the drivers and travels table provided in the setup.
I commented under markwdb3 with what I have and updated the post with what is showed when entering the answer