If you want to store redirects in database use the module Redirect. This module provides a user interface to add redirects. The redirects are stored in a content entity, which you can also create programmatically:
'redirect_source' => 'redirects/redirect1',
'redirect_redirect' => 'internal:/node/1',
'language' => 'und',
'status_code' => '301',
You can do this at the time you create nodes from imported data or you could put code in entity hooks which updates the redirects when creating, editing or deleting a node.