State the steps involved in query processing. Why is the query optimization needed?
Query processing refers to the range of activities involved in extracting data from a database. The activities include translation of queries in high-level database languages into expressions that can be used at the physical level of the file system, a variety of query-optimizing transformations, and actual evaluation of queries. A database query is the vehicle for instructing a DBMS to update or retrieve specific data to/from the physically stored medium.
There are three phases that a query passes through during the DBMS’ processing of that query:
Purpose of the Query Optimizer
The optimizer attempts to generate the best execution plan for a SQL statement. The best execution plan is defined as the plan with the lowest cost among all considered candidate plans. The cost computation accounts for factors of query execution such as I/O, CPU, and communication.
The best method of execution depends on numerous conditions including how the query is written, the size of the data set, the layout of the data, and which access structures exist. The optimizer determines the best plan for a SQL statement by examining multiple access methods, such as full table scan or index scans, and different join methods such as nested loops and hash joins.
Because the database has many internal statistics and tools at its disposal, the optimizer is usually in a better position than the user to determine the best method of statement execution. For this reason, all SQL statements use the optimizer.
Consider a user who queries records for employees who are managers. If the database statistics indicate that 80% of employees are managers, then the optimizer may decide that a full table scan is most efficient. However, if statistics indicate that few employees are managers, then reading an index followed by a table access by rowed may be more efficient than a full table scan.
Define BCNF. How does it differ from 3NF? Why is it considered stronger than 3NF?
Draw the ER diagram of a hospital and explain.
Find the time complexity of Binary Search Algorithm.
What are tunnelling and encapsulation in the context of mobile IP?
Explain Sequence and Activity diagram with example.