You could handle it like wordpress does permalinks. It has .htaccess rewrite rules that essentially say if the request is not in the server file structure, send it to WP for handling. Then WP examines the request to see if matches the permalink structure that resolves to an actual entry. Only if unsuccessful is a 404 returned.
You would have to have .htaccess forward such a request to your url parser instead of wordpress. Then only if the url does not exist in your table, pass the request on to WP for further processing, assuming you are using permalinks. Otherwise, immediately return a 404 page.