Solutions to Practice Questions - Chapter 6 docx

6 373 0
Solutions to Practice Questions - Chapter 6 docx

Đang tải... (xem toàn văn)

Thông tin tài liệu

¤NIIT S.1 1. c. Primary XML index 2. In a clustered index, data is stored at the leaf level of the B-Tree. The SQL Server performs the following steps when it uses a clustered index to search for a value: a. The SQL Server obtains the address of the root page from the sysindexes table, which is a system table containing the details of all the indexes in the database. b. The search value is compared with the key values on the root page. c. The page with the highest key value less than or equal to the search value is found. d. The page pointer is followed to the next lower level in the index. e. Steps 3 and 4 are repeated until the data page is reached. f. The rows of data are searched on the data page until the search value is found. If the search value is not found on the data page, no rows are returned by the query. 3. d. You need not drop XML indexes in order to modify the primary key on a table. 4. Using the sys.dm_db_index_physical_stats system function 5. WITH ENCRYPTION option 6. A standard view does not contain any data, but derives its data from the underlying tables. However, in the indexed view, the rows of the view are stored in the database in the same format as a table. 7. Indexing a view helps in improving the query performance. Another benefit of creating an indexed view is that the optimizer starts using the view index in queries that do not directly name the view in the FROM clause. If the query contains references to columns that are also present in the indexed view, and the query optimizer estimates that using the indexed view offers the lowest cost access mechanism, the query optimizer selects the indexed view. 8. The full-text search feature helps you to search for complex strings in the database. It also helps in improving the query performance when the data in a table is large. 9. The full-text index population methods are: z Full population: Use this method to populate the full-text catalog or the full- text index for the first time z Change tracking-based population: Use this method to propagate the changes made in the table to the full-text index. Solutions to Practice Questions Chapter 6 S.2 ¤NIIT z Incremental timestamp-based population: Use this method to update the full- text index for rows added, deleted, or modified after the last population or while the last population was in progress. 1. Batches allow executing a set of statements together. This helps in submitting a set of SQL statements together to the database engine. All the statements are compiled together and an execution plan is created to execute the statements. 2. Local variables can be used within a batch in which they are declared. 3. To return the status of execution, you can use the RETURN statement. To return more than one value from a procedure, you can use the OUTPUT statements. 4. b. WHILE statement 5. In SQL Server 2005, you can handle error using the following two ways: z TRY-CATCH block: This block is used to write a set of statement to handle the error in the database engine z RAISERROR statement: This statement allows raising an error and sending it to the application that is executing the statement. 6. RAISERROR statement allows raising an error and sending it to the application that is executing the statement. 7. User-defined function are the functions that are created by the users. These functions accept parameters and return output as a single value or a table. 8. The scalar functions operate on a single value and return single data value based on the input value and the type specified in the RETURNS clause. The table-valued functions return a table as output, which can be derived as a part of a SELECT statement. 1. Triggers are a special kind of stored procedures, which are fired in response to an action. 2. Triggers are of following types: z DML Triggers z DDL Triggers 3. A transaction is used to execute a sequence of statements together as a single logical unit of work. 4. Transactional concurrency is the ability of multiple transactions to access or change the shared data at the same time. Chapter 7 Chapter 8 ¤NIIT S.3 5. Transactional concurrency causes the following problems: z Lost updates z Uncommitted dependency z Inconsistent analyses z Phantom reads 6. Phantom read is the problem which arises due to reading a quasi-updated data. 7. A shared lock locks the resource from being updated if any other transaction is reading or updating it. However, any transaction can read the resource. Whereas, in case of an exclusive lock no transaction can read or update the data when it is in use by any other transaction. 8. In order to detect deadlock situations, SQL Server scans for sessions that are waiting for a lock request. SQL Server, during the initial scan, marks a flag for all the waiting sessions. When SQL Server scans for sessions for the second time, a recursive deadlock search starts. If any circular chain of lock requests is found, SQL Server then cancels the least expensive transaction and marks that transaction as the deadlock victim. 9. Update helps in preventing deadlock as SQL Server allows only one transaction to obtain an update lock on a resource at a time. 1. CLR is an environment that executes codes written in .NET programming languages. 2. The syntax of creating an assembly is: CREATE ASSEMBLY assembly_name [ AUTHORIZATION owner_name ] FROM { <client_assembly_specifier> | <assembly_bits> [ , n ] } [ WITH PERMISSION_SET = { SAFE | EXTERNAL_ACCESS | UNSAFE } ] 3. In any of the following conditions, you need to use managed code: z Complicated programming logics z Codes requiring access to external resources z Programming logic that needs to use .NET Framework base class library 4. To enable CLR in a database, you need to use the following statement: sp_configure CLR_ENABLED, 1 Chapter 9 S.4 ¤NIIT 5. While creating a managed function, you need to create a “context connection” with the SQL Server. 1. A Web service is a collection of methods that provide a specific functionality. Web Services access data on some predefined set of business logics from the server and return the data to the client. 2. Native Web services provide the following benefits: a. Allow Web applications to access data from SQL Server b. Provide supports for mobile clients 3. SOAP refers to Simple Object Access Protocol. It defines how to use XML and HTTP to access services, objects, and servers regardless of the operating system. 4. Following statement is used to create an HTTP Endpoint: CREATE ENDPOINT endpoint_name STATE = { STARTED | STOPPED | DISABLED } AS HTTP ( AUTHENTICATION =( { BASIC | DIGEST | INTEGRATED | NTLM | KERBEROS }, PATH = 'url', PORTS = (CLEAR) ) FOR SOAP( [ { WEBMETHOD [ 'namespace' .] 'method_alias' ( NAME = 'database.owner.name' [ , SCHEMA = { NONE | STANDARD | DEFAULT } ] [ , FORMAT = { ALL_RESULTS | ROWSETS_ONLY } ]) } [ , n ] ] [ BATCHES = { ENABLED | DISABLED } ] [ , WSDL = { NONE | DEFAULT | 'sp_name' } ] 5. FORMAT specifies whether a row count, error messages, and warnings are returned with the result set. The default value is ALL_RESULTS. 6. You can secure an endpoint by the following tasks: z Create appropriate user accounts within the database access. z Grant permissions for any stored or user-defined functions that the user or roles need to access using the web service. z Grant permissions to allow users or roles to connect to HTTP endpoints. Chapter 10 ¤NIIT S.5 1. Service Broker provides a durable messaging framework, which ensures the delivery and process of the message. 2. In Service Broker, a message is the data exchanged by Service Broker applications. 3. A queue is a placeholder for Messages. As a service receives a message, it is placed in the queue and the service program retrieves the message from the queue. 4. You need to use CREATE QUEUE command to create a queue. The syntax of CREATE QUEUE command is: CREATE QUEUE <object> [ WITH [ STATUS = { ON | OFF } [ , ] ] [ RETENTION = { ON | OFF } [ , ] ] [ ACTIVATION ( [ STATUS = { ON | OFF } , ] PROCEDURE_NAME = <procedure> , MAX_QUEUE_READERS = max_readers , EXECUTE AS { SELF | 'user_name' | OWNER } ) ] ] 5. To send a message from one service to another, you need to use SEND statement. The syntax of SEND statement is: SEND ON CONVERSATION conversation_handle [ MESSAGE TYPE message_type_name ] [ ( message_body_expression ) ] [ ; ] 6. Asynchronous communication is a feature of Service Broker that ensures that multiple transactions can be handled at a single point of time. 7. Reliable query processing is a feature of Service Broker that ensures that whenever a query is executed, it must be committed in the server. Chapter 11 S.6 ¤NIIT . table to the full-text index. Solutions to Practice Questions Chapter 6 S.2 ¤NIIT z Incremental timestamp-based population: Use this method to update the full- text index for rows added, deleted,. method to populate the full-text catalog or the full- text index for the first time z Change tracking-based population: Use this method to propagate the changes made in the table to the full-text. statements together. This helps in submitting a set of SQL statements together to the database engine. All the statements are compiled together and an execution plan is created to execute the

Ngày đăng: 31/07/2014, 15:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan