Monday, February 24, 2014

SQL - கேள்வி பதில் பகுதி - 4

Q 31. Explain why you would want to join data so that users can easily work with it.

A. A normalized database is not always easy for the user to work with. For example, only the CustomerID is  stored in the Orders table. The Company Name is stored in the Customers table. To see both the Customer and Order information, the user must join the tables. Using a view, you can join the tables for the user, so that the user can work with the view as if it were a single table.

Q 32. Explain what it means to customize data to a user's needs.

A. Using a view, you can create a column that combines first, middle, and last name of an employee, or the city, state, and zip code from an address. This makes it much easier for the user to work with this data.

Q 33. How do views help you to secure data?

A. You can grant rights to logins and roles to the views that you create. It is not necessary to grant rights to the underlying tables. In this way you can give users access to just desired columns and rows. For example, you can give users rights to name and address data for the sales department in the employee table.
Q 34 Explain what an indexed view is and why it is beneficial.

A With indexed views, you provide a unique, clustered index for a view. This means that SQL server stores the data in the designated order at the time that you save the view. It updates the index as you add, update, and delete data. Therefore, there is no need for SQL Server to create a result set dynamically each time the view is referenced.

Q 35 Describe the benefits of user-defined functions when working with views.

A User-defined functions enable you to pass parameters to functions as if they were stored procedures, but to work with the results as if they were views.

Q 36 Explain how you can use a view to secure data.

A You first create a view containing the appropriate columns. You then give the users rights to the view. Although they have no rights to the underlying tables, they are able to work with the data displayed in the view.

Q 36. What happens if you forget to use BEGIN and END with the IF...ELSE...ENDIF construct?

A. If you forget to place a BEGIN...END construct on the line immediately following the IF statement or the ELSE statement, only the first statement after the IF or the ELSE executes.

Q 37. What does the RETURN statement do?

A. The RETURN statement unconditionally exits a stored procedure without executing any other statements.

Q 38. Why would you use the CASE statement?

A. You use the CASE statement to compare a result from a SQL statement against a set of simple responses. For example, a CASE statement might evaluate the contents of the ContactTitle field and return an appropriate string based on those contents.

Q 39. Why would you use the SET NOCOUNT statement?

A. When it is set to ON, SET NOCOUNT eliminates the xx row(s) affected message in the SQL Express Manager window and the DONE_IN_PROC communicated from SQL Server to the client application. This improves the performance of the stored procedure.

Q 40. The @@ functions are actually variables (true/false).

A. False. You cannot assign values to them or work with them like normal variables. They are instead functions that return information about SQL Server.

No comments:

Post a Comment