Update customer credit score on address update:
- Given a table of customer data with name, address, credit score, and date of last address update columns,
- write a trigger that will automatically update the customer's credit score whenever their address is updated.
- Output will be the customer table with updated credit scores.
About this solution: The trigger above will update the credit score of the customer whenever their address is updated. This is a good solution that solves the problem. The trigger is optimal because it will only update the credit score of the customer whose address was updated.
Write a trigger that will update the total salary for each department when an employee's salary is updated.
About this solution: The trigger above is a good solution that solves the problem. It is efficient because it only updates the department table when the employee table is updated.
This technical problem describes how to write a SQL trigger that will automatically update the "last_updated" column whenever a change is made to any of the other columns in a table. The example input table contains employee data, and the example output shows how the "last_updated" column would be updated after a change is made to one of the other columns.
About this solution: The candidate's solution is correct and demonstrates a good understanding of how to write a SQL trigger.
Write a trigger that updates a customer's balance field in a customer table whenever a new purchase is made, using data from a purchase table.
About this solution: The trigger will automatically update the customer's balance field whenever a new purchase is made, which is the desired outcome. The approach is sound and the trigger is executed only when needed, so this is a good solution.
This technical problem describes how to create a trigger that will prevent a user from inserting a row into a table if the user's id is not in the table.
About this solution: The candidate's solution is complete and solves the problem. The approach is generally sound.
A trigger is needed that will update the "last_updated" column in a table every time a row is inserted or updated.
About this solution: The candidate's solution is complete and solves the problem. The approach is optimal because it only updates the last_updated column for the row that was inserted or updated.