Move the ClearConfigTables function into the DbConnection class.

Refs #5565
Re-use IDs where possible.

Refs #5565
Merge branch 'feature/ido-reuse-ids-5565' into next

Fixes #5565