Searching for "Inventory."

Q:

You are the administrator of a SQL Server 2000 computer. The server contains a database named Inventory. The database has a Parts table that has a field named InStock.When parts are shipped, a table named PartsShipped is updated. When parts are received, a table named PartsReceived is updated. The relationship of these tables is shown in the exhibit. (Click the Exhibit button.)

You want the database to update the InStock field automatically. What should you do?

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.
 
Answer & Explanation Answer: A) Add triggers to the PartsShipped and the PartsReceived tables that update the InStock field in the Parts table.

Explanation:

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.

Report Error

View Answer Report Error Discuss