|A) Add triggers to the PartsShipped and the PartsReceived tables that update the InStock field in the Parts table.||B) Use a view that creates anInStock field as part of an aggregate query.|
|C) Create stored procedures for modifying the PartsReceived and the PartsShipped tables that also modify the InStock field in the Parts table. Use these procedures exclusively when modifying data in the PartsReceived and the PartsShipped tables.||D) Create a user-defined function that calculates current inventory by running aggregate queries on the PartsShipped and PartsReceived tables.|
Triggers are a special class of stored procedure defined to fire automatically when an UPDATE, INSERT, or DELETE statement is issued against a table or view. They are powerful tools that can be used to enforce business rules automatically when data is modified. Triggers can extend the integrity checking logic of SQL Server constraints, defaults, and rules, although constraints and defaults should be used instead whenever they provide all the needed functionality. In this scenario an AFTER UPDATE trigger can be used to update the tables to update the PartsShipped and the PartsReceived tables that update the InStock column in the parts table.