All CompTIA exams
Free DS0-002 practice test: 30 questions with answers
30 original questions for CompTIA DataSys+ (V2), drawn from every topic area. Answer each one to see whether you got it right and why. No sign-up.
- Free questions
- 30
- Full bank
- 100 questions
- Real exam
- Maximum of 90 questions, 90 min
- Passing score
- 700 (scale 100-900)
All 30 DS0-002 questions with answers
The same questions as the test above, grouped by exam topic. Open any question to see the answer and explanation.
Database Fundamentals (5 questions)
Question 1
A table stores customer orders, and each order must reference exactly one existing customer. Which constraint enforces this relationship?
- AA check constraint on the orders table that limits the order total to a fixed amount
- BA default value on the customer name column that fills in a placeholder name for new rows
- CA unique index on the order date to prevent duplicate dates
- DA foreign key from the orders table to the customers table's primary key
Show answer and explanationHide answer
Correct answer: DA foreign key ensures each order references an existing customer through the primary key. A unique date index, a total check and a default name do not enforce the relationship.
Question 2
Which SQL statement returns each customer's name with the total of their orders, including customers with no orders?
- AAn INNER JOIN with a WHERE clause that removes customers with no matching orders
- BA DELETE statement that removes customers with no orders from the customers table
- CA LEFT OUTER JOIN from customers to orders with GROUP BY on the customer and COUNT or SUM of orders
- DAn UPDATE that sets the total to zero for every customer row in the customers table
Show answer and explanationHide answer
Correct answer: CA left outer join keeps customers without orders, and aggregation over the grouped results returns totals. An inner join removes customers without orders, and DELETE or UPDATE do not return a query result.
Question 3
A developer writes a query that concatenates user input directly into a SQL string. What vulnerability does this create, and what is the fix?
- ADenial of service from full table scans, fixed by adding an index
- BSQL injection, fixed by parameterized queries or prepared statements
- CReplication lag on the standby, fixed by reducing the batch size
- DIndex fragmentation in a heap, fixed by rebuilding the table
Show answer and explanationHide answer
Correct answer: BConcatenated input can change the query's meaning, which is SQL injection. Parameterized queries separate data from SQL. Indexes, batch sizes and rebuilds do not address injection.
Question 4
Which data type is most appropriate for storing monetary values in a relational database to avoid rounding errors?
- ADECIMAL or NUMERIC with a defined precision and scale
- BBOOLEAN with a yes or no flag per account record
- CFLOAT for exact currency amounts across reports
- DVARCHAR storing the amount as text for display
Show answer and explanationHide answer
Correct answer: ADECIMAL and NUMERIC store exact values with defined precision and scale, which suits currency. FLOAT stores approximations, text complicates arithmetic, and booleans cannot hold amounts.
Question 5
A stored procedure must be reused by several applications to insert orders consistently. Which benefit is most relevant?
- AReplacing the need for user permissions on tables when applications connect through a single account
- BCentralized logic and fewer round trips when several statements run together on the server
- CAutomatic backup of every table on a nightly schedule with point-in-time recovery enabled by default
- DRemoving the need for primary keys in normalized tables when stored procedures run
Show answer and explanationHide answer
Correct answer: BStored procedures centralize logic and can reduce network round trips. They do not perform backups, remove keys or replace permissions.
Database Deployment (5 questions)
Question 6
A team is designing a new database schema and wants a shared reference of tables, columns, data types, and their meaning. Which artifact should be created?
- AA wallpaper for the database server
- BA data dictionary
- CA marketing brochure
- DA customer invoice template
Show answer and explanationHide answer
Correct answer: BA data dictionary documents tables, columns, types and definitions. The other artifacts are unrelated to schema documentation.
Question 7
A database must be deployed in a cloud environment with high availability across two zones. Which configuration is most appropriate?
- AA managed database with zone-redundant or multi-zone deployment
- BManual copies of the database files every month to an external drive
- CA single instance in one zone with no backups and no automated failover
- DA database on a laptop for production use with a local USB disk as storage
Show answer and explanationHide answer
Correct answer: AMulti-zone or zone-redundant deployments provide high availability across zones. Single-zone deployments, laptops and monthly manual copies do not meet the requirement.
Question 8
An application connects to a database through a load balancer that distributes connections across read replicas. Which requirement must the application follow for this to work safely?
- AWrites must be sent to random replicas in round-robin order by connection
- BReplicas must be shut down during business hours while the primary handles every read and write
- CWrites must go to the primary and reads can go to replicas that may lag slightly
- DThe load balancer must cache query results forever in memory for every session without invalidation
Show answer and explanationHide answer
Correct answer: CWrites belong on the primary, while replicas serve reads that may be slightly behind. Random writes, shutdowns and permanent caching are not safe designs.
Question 9
Before deploying a schema change to production, the team wants to confirm that the change works and that application queries still perform as expected. Which step should come first?
- AApplying the change directly to production during peak hours without a rollback plan or a backup taken first
- BTesting the change in a staging environment with representative data and workloads
- CSkipping testing because the change is small and the rename looks trivial
- DDeleting the old schema before testing the new one, along with the legacy columns used by reports
Show answer and explanationHide answer
Correct answer: BStaging tests with representative data and workloads reveal failures and performance regressions before production. Direct production changes, skipping tests and deleting schemas first are risky.
Question 10
A database administrator must document the standard steps for applying patches to production databases. Which document should be created?
- AA wallpaper design guide for the office lobby color scheme
- BA holiday schedule for staff vacation days
- CA standard operating procedure (SOP) for patching
- DA marketing campaign plan for spring promotions
Show answer and explanationHide answer
Correct answer: CAn SOP documents repeatable steps, roles and checks for patching. The other documents are not operational procedures for databases.
Data and Database Security (5 questions)
Question 11
What does data masking primarily protect?
- ANetwork cable length between the application tier and the storage array
- BDisk partition labels assigned during the operating system installation
- CSensitive values from being seen by unauthorized users in non-production or reports
- DThe server's power supply unit rated for 1200 watts with dual hot-swap modules
Show answer and explanationHide answer
Correct answer: CMasking hides sensitive values from users who should not see them, especially outside production. The other items are unrelated.
Question 12
Which two practices help protect database credentials? (Choose two.)
- AHardcoding credentials in source code
- BReusing one password for all systems
- CStoring secrets in a secrets manager
- DRotating passwords and using unique accounts
- EWriting passwords in a shared spreadsheet
Show answer and explanationHide answer
Correct answer: C, DSecrets managers and rotation with unique accounts reduce credential exposure. Shared spreadsheets, hardcoded credentials and reused passwords expose them.
Question 13
A database contains personal data, and the security team wants developers to see realistic-looking values without seeing real personal information. Which technique fits best?
- AGiving developers full production access with a note asking them to be careful
- BStoring personal data in comments
- CCopying production data to personal laptops
- DData masking of sensitive columns for non-production use
Show answer and explanationHide answer
Correct answer: DMasking produces realistic but non-identifying values for development and testing. Full access, personal copies and comments expose personal data.
Question 14
Sensitive columns must be encrypted so that database administrators cannot read the plaintext values. Which approach best meets this requirement?
- AEncrypting the entire server volume with a password written on a sticky note taped beside the rack
- BStoring the keys in the same table as the encrypted data columns for speed
- CUsing base64 encoding as protection for the stored values in production
- DColumn-level encryption with keys managed separately from the database administrators
Show answer and explanationHide answer
Correct answer: DColumn encryption with separately managed keys prevents administrators from reading plaintext. Keys stored with data, sticky notes and base64 encoding do not provide that protection.
Question 15
Which access control approach gives each application account only the permissions it needs on specific tables?
- ALeast-privilege database roles granted per application, with specific object permissions
- BGiving every application the db_owner role on the production database server
- COne shared administrator account for every application using one password
- DGranting public access to every table in the reporting schema for convenience
Show answer and explanationHide answer
Correct answer: ALeast-privilege roles with specific object permissions limit each application's access. Shared admin accounts, public access and db_owner for all applications violate least privilege.
Database Management and Maintenance (5 questions)
Question 16
A monitoring alert shows that a database's disk usage will reach capacity in two weeks. What is the most appropriate first action?
- ADeleting the transaction logs to free space immediately on the production server
- BReviewing growth trends and planning storage expansion or data archiving before capacity is reached
- CIgnoring the alert until the disk is full and assuming autogrowth will keep working on the current volume
- DRebooting the database server every night as a scheduled task to keep temp space available
Show answer and explanationHide answer
Correct answer: BTrend review and planned expansion or archiving prevents an outage before it happens. Deleting transaction logs can break recovery, ignoring alerts causes outages, and rebooting does not free disk.
Question 17
A query that used to run quickly now takes minutes after a data load. Which step is the most appropriate first troubleshooting action?
- AAdding more users to the database connection pool to spread the query load across sessions and tenants
- BDropping every index on the affected tables to free space and then rebuilding them later during business hours
- CRestarting the database server without analysis during the load window, which may clear cached plans and hide the root cause
- DReviewing the query execution plan and checking whether statistics and indexes are current
Show answer and explanationHide answer
Correct answer: DExecution plans and up-to-date statistics and indexes reveal why performance changed after the load. Restarting, adding users and dropping indexes are unfocused or harmful.
Question 18
A database index is slowing writes heavily and is rarely used by queries. What is the most appropriate action?
- AReviewing index usage statistics and removing or consolidating the unused index after testing
- BAdding more indexes on the same columns with different sort orders and included columns for reporting
- CDisabling statistics collection permanently on every table so the optimizer relies on outdated row estimates
- DStoring the index keys and values in a plain text file on disk for quick reads
Show answer and explanationHide answer
Correct answer: AReviewing usage and removing unused indexes after testing reduces write overhead without harming queries. Adding indexes increases writes, disabling statistics harms the optimizer, and text files are not indexes.
Question 19
Database integrity checks report corruption on a table. What should the administrator do first?
- ARunning an in-place repair command such as DBCC CHECKDB with REPAIR_ALLOW_DATA_LOSS on the production database during peak hours without a backup
- BDeleting the corrupted table outright with DROP TABLE and recreating it empty from the application's schema scripts before anyone checks the data
- CIsolating the affected table, verifying the most recent good backup, and planning a restore or repair under change control
- DIgnoring the integrity check report because the application still returns results for most queries and the errors appear in the nightly job logs
Show answer and explanationHide answer
Correct answer: CIsolation, verifying a good backup and planned repair protect data while fixing corruption. Unplanned repairs without backups, deletion and ignoring reports risk permanent loss.
Question 20
A database log file grows continuously and fills the disk. The database uses full recovery mode and no log backups are taken. What is the root cause?
- AThe server's time zone is incorrect for the host clock
- BThe application uses too many tables across the schema
- CLog backups are not being taken, so the log cannot be truncated
- DThe database has too many users connected at one time
Show answer and explanationHide answer
Correct answer: CIn full recovery mode, the transaction log is truncated only after log backups. Without them, the log keeps growing. User counts, time zones and table counts do not cause this behavior.
Business Continuity (5 questions)
Question 21
Which backup type copies only the data that changed since the last full backup?
- AOS disk snapshot
- BPrinted report backup
- CFull database backup
- DDifferential backup
Show answer and explanationHide answer
Correct answer: DA differential backup captures changes since the last full backup. A full backup copies everything, OS snapshots are not database backups, and print backups are not backup types.
Question 22
Which two factors affect the choice of backup frequency? (Choose two.)
- AThe rate at which data changes
- BThe brand of the backup software
- CThe color of the backup report
- DThe number of users in the marketing team
- EThe acceptable data loss for the business
Show answer and explanationHide answer
Correct answer: A, EAcceptable data loss and the rate of change determine how often backups must run. Software brands, report colors and team sizes do not drive frequency.
Question 23
A company has a recovery time objective of one hour and a recovery point objective of 15 minutes for a critical database. Which backup strategy best meets these targets?
- ANo backups because the system is redundant across two data centers and clusters
- BFrequent transaction log backups combined with a replicated standby that can be promoted quickly
- CA weekly full backup stored on the same server as the production database, with daily differential backups kept on that host
- DA monthly tape archive stored offsite with a courier pickup every thirty days and a restore lag of several days
Show answer and explanationHide answer
Correct answer: BLog backups every few minutes and a standby that can be promoted meet a 15-minute recovery point and a one-hour recovery time. Weekly, monthly and no backups cannot meet those objectives.
Question 24
A disaster recovery site must be ready to take over within minutes with current data. Which DR strategy fits this requirement?
- ACold site with no hardware or data
- BHot standby with continuous replication
- CBackup tapes shipped after the disaster
- DRestoring from a paper record
Show answer and explanationHide answer
Correct answer: BA hot standby with continuous replication is ready for rapid failover with current data. Cold sites, shipped tapes and paper records take much longer and lose more data.
Question 25
A database backup completed successfully, but a restore test fails. What is the most important lesson for the disaster recovery plan?
- ABackups are unnecessary once the nightly job log reports success
- BBackups must be validated through regular restore tests, not assumed to work
- CThe restore test can be skipped because the backup job succeeded
- DThe backup file size alone determines recoverability in practice
Show answer and explanationHide answer
Correct answer: BA completed backup does not prove it can be restored, so regular restore tests are required. The other statements assume recoverability without evidence.
Data Integration (5 questions)
Question 26
A nightly ETL job loads data from several source systems into a warehouse, and the load fails when a source adds a new column. Which practice reduces this risk?
- AIgnoring schema changes because the warehouse data is read-only and loads continue to run regardless
- BValidating source schemas and handling schema changes with versioned mappings and alerts
- CRenaming the warehouse tables every night with a date suffix so downstream reports reference the new name
- DRemoving the ETL job entirely and loading each source by hand through a spreadsheet export each morning
Show answer and explanationHide answer
Correct answer: BSchema validation, versioned mappings and alerts catch and manage source changes before they break loads. Ignoring changes, renaming tables and removing jobs do not solve the problem.
Question 27
A data quality check finds that some customer records have invalid postal codes. Which action should be taken first?
- AIgnoring the issue because invalid codes affect a small percentage of rows in the extract
- BChanging every postal code in the customer table to the same placeholder value
- CDeleting every customer with unusual postal codes without review from the CRM
- DProfiling the data to identify the cause and applying validation rules at the source where possible
Show answer and explanationHide answer
Correct answer: DProfiling identifies the root cause and validation at the source prevents recurrence. Mass deletion, ignoring issues and overwriting values damage data quality.
Question 28
An ELT process loads raw data into a cloud warehouse, then transforms it inside the warehouse. What is the main advantage of this pattern?
- AIt skips the need for data quality checks since loads are trusted
- BIt removes every need for a data model, so raw tables can be queried directly by analysts
- CIt uses the warehouse's compute to transform data at scale after loading raw data
- DIt stores data in plain text files exported from the source systems on a schedule
Show answer and explanationHide answer
Correct answer: CELT uses scalable warehouse compute after loading raw data, which supports flexible transformations. It still requires quality checks and a data model, and it is not limited to text files.
Question 29
A connection between an integration tool and a database fails intermittently with timeouts. Which troubleshooting step is most useful first?
- AChanging the database name and the connection string so that the integration tool points to a renamed instance on another host
- BRestarting the integration tool's logo and splash screen so the user interface reloads its branding assets before the job runs
- CChecking network connectivity, firewall rules, and connection pool settings between the tool and the database
- DDeleting the integration job and its checkpoint table so the next run rebuilds the target from scratch without first testing the link
Show answer and explanationHide answer
Correct answer: CNetwork paths, firewall rules and connection pools are the common causes of intermittent timeouts. Renaming databases, logos and deleting jobs do not address connectivity.
Question 30
Which two practices improve data quality in a pipeline? (Choose two.)
- ALogging rejected records with reasons for review
- BLoading all records even when they fail validation without review
- CChanging source data without notice
- DIgnoring duplicate records
- EValidating records against rules at load time
Show answer and explanationHide answer
Correct answer: A, EValidation at load and logging rejected records with reasons improve quality. Unreviewed loads, silent source changes and ignored duplicates degrade data.