Write a SQL query to check whether a given directory is correct, given a table with the directory details. Asked in the Technical 3 stage. For this exercise, evaluate the directory path /claims/archive.
Return whether the requested directory exists, has a valid parent, and matches the path derived from its parent and directory name.
/claims/archive.directory_path, is_correct, and validation_status.is_correct to a boolean and validation_status to a concise reason such as valid_directory, path_mismatch, or parent_directory_not_found.is_correct as false and validation_status as directory_not_found when /claims/archive has no matching row.parent_directory_path NULL as valid only when directory_path is / and directory_name is empty; otherwise use invalid_root.NULL parent directory row for non-root directories; otherwise return false and parent_directory_not_found./ characters from parent_directory_path, then appending / and directory_name.false and path_mismatch when the stored path differs from the derived path; otherwise return true and valid_directory.| Column | Type | Description |
|---|---|---|
| directory_pathPK | VARCHAR(255) | Full path identifying the directory |
| parent_directory_path | VARCHAR(255) | Full path of the directory's parent; NULL for the root directory |
| directory_name | VARCHAR(100) | Directory name stored for path validation |