CompTIA DataSys+ (DS0-002) free question 3 / 10 · Domain 2: Database Deployment
A DBA creates dozens of tenant databases with CREATE DATABASE and wants them to start from a prepared baseline. What do the template databases created by initdb provide?
- Backup copies that the server restores when a tenant database fails
- Replica databases that the server keeps current with the tenant databases
- Log databases that record the changes made in the tenant databases
- Source databases that CREATE DATABASE copies as a starting point
Show the answer and explanation
Answer: D
Why this is correct
The initdb page lists template1 and template0 among the databases created with a new cluster and says they are meant as source databases to be copied by later CREATE DATABASE commands. The postgres database is a default database for users, utilities and third-party applications. A prepared baseline therefore lives in template1, and new databases start as copies of it. The source reads: "template1 and template0 are meant as source databases to be copied by later CREATE DATABASE commands." Source page: initdb, section "Description".
Why the other options are wrong
"Backup copies that the server restores when a tenant database fails" … The templates are source databases for new databases. They are not backups of existing ones.
"Replica databases that the server keeps current with the tenant databases" … A template is copied when a database is created. It is not kept in step with the databases made from it.
"Log databases that record the changes made in the tenant databases" … Change records are kept in the write-ahead log. The templates are starting points for new databases.
Key points
New databases are created by copying a template database.