Move the ClearConfigTables function into the DbConnection class.

Refs #5565
Re-use IDs where possible.

Refs #5565