How to Create a Database Question
Database questions in TestTrick allow you to assess a candidate’s ability to write SQL queries using predefined schemas, sample data, and test-case-based evaluation.
Open the Database Question Creator
Go to Step 2: Add Questions while creating or editing a test.
Click the Code question card.

From the modal, select Database.

The Database Question Creation page will open.

Add Question Details
Question Title
- Enter a clear title describing the database task.

Question Description
- Define the problem statement clearly.
- Explain what data needs to be retrieved, inserted, updated, or analyzed.

Add Database Schema
Add the database schema using MySQL.
- You can define:
- Multiple tables
- Relationships
- Data types and constraints

Click Validate Schema to verify correctness.
The schema must be validated before proceeding.

Provide the Solution Query
-
Add the correct SQL solution query for the problem.
This solution is used for Validating candidate responses

Test the Solution
- Click Test Solution to ensure:
- The schema executes correctly
- The solution query produces valid result.

Show Code Stub (Optional)
- Enable Show Code Stub if you want to provide Initial MySQL code for candidates
- This can help guide candidates, especially for complex queries.

Scoring & Weightage
-
Database questions following below scoring rules.
You can:
- Change the weightage of the question
- Mark the question as unscorable if manual evaluation is required
Unscorable questions are not included in the average assessment score.
Candidate Experience
- Candidates view the database schema.
- They write MySQL queries to solve the problem.
- Their output is matched against the expected test-case result.
- Pass/fail and scoring are determined automatically unless set as unscorable.
Summary
Database questions in TestTrick allow you to:
- Define complex schemas with multiple tables
- Validate schemas before publishing
- Evaluate SQL queries using solution-based test cases
- Provide optional code stubs for guidance
- Control scoring with weightage or manual evaluation