You are on page 1of 9

3.

6 Query Processing
•Upper levels of the data integration problem

•Basic Steps in Query Processing


3.6.1 Upper levels of the data integration problem

• How to construct mappings from sources to a single mediated schema

• How queries posed over the mediated schema are reformulated over the sources

3.6.2 Basic Steps in Query Processing

1. Parsing and translation

2. Optimization

3. Evaluation
Parsing and translation

Translate the query into its internal form. This is then translated into relational algebra. Parser checks
syntax, verifies relations.

Evaluation

The query-execution engine takes a query-evaluation plan, executes that plan, and returns the answers
to the query.A relational algebra expression may have many equivalent expressions. Each relational
algebra operation can be evaluated using one of several different algorithms. Correspondingly, a
relational-algebra expression can be evaluated in many ways. Annotated expression specifying
detailed evaluation strategy is called an evaluation-plan.

Query Optimization

Amongst all equivalent evaluation plans choose the one with lowest cost. Cost is estimated using
statistical information from the database catalog
Basic Steps in Query Processing

1. Parsing and translation


2. Optimization
3. Evaluation
Basic Steps in Query Processing (cont.)

• Parser and translator


• translate the (SQL) query into relational algebra
• Parser checks syntax, verifies relations

• Evaluation engine
• The query-execution engine takes a query-evaluation plan, executes that plan, and returns the
answers to the query executes that plan, and returns the answers to the query

• Optimizer (in a nutshell -- more details in the next slides)


• Chooses the most efficient implementation to execute the query
• Produces equivalent relational algebra expressions
• Annotates them with instructions (algorithms)
3.7 SQL

SQL is Structured Query Language, which is a computer language for storing, manipulating and retrieving
data stored in relational database.

SQL is the standard language for Relation Database System. All relational database management systems
like MySQL, MS Access, and Oracle, Sybase, Informix, postgres and SQL Server use SQL as standard
database language.

3.7.1 Why SQL?

•  Allows users to access data in relational database management systems.


•  Allows users to describe the data.
•  Allows users to define the data in database and manipulate that data.
•  Allows to embed within other languages using SQL modules, libraries & pre-compilers.
•  Allows users to create and drop databases and tables.
•  Allows users to create view, stored procedure, functions in a database.
•  Allows users to set permissions on tables, procedures, and views
3.7.2 History

• 1970 -- Dr. Edgar F. "Ted" Codd of IBM is known as the father of relational databases. He described a
relational model for databases.
• 1974 -- Structured Query Language appeared.
• 1978 -- IBM worked to develop Codd's ideas and released a product named System/R.
• 1986 -- IBM developed the first prototype of relational database and standardized by ANSI.

The first relational database was released by Relational Software and its later becoming Oracle

3.7.3 SQL Process

When you are executing an SQL command for any RDBMS, the system determines the best way to carry out
your request and SQL engine figures out how to interpret the task.

There are various components included in the process. These components are Query Dispatcher,
Optimization Engines, Classic Query Engine and SQL Query Engine, etc. Classic query engine handles all
non-SQL queries but SQL query engine won't handle logical files.
3.7.4 SQL Commands

The standard SQL commands to interact with relational databases are CREATE, SELECT, INSERT,
UPDATE, DELETE and DROP. These commands can be classified into groups based on their nature.

3.7.4.1 DDL - Data Definition Language

Command Description

• CREATE Creates a new table, a view of a table, or other object in database

• ALTER Modifies an existing database object, such as a table.

• DROP Deletes an entire table, a view of a table or other object in the database.
3.7.4.2 DML - Data Manipulation Language 3.7.4.3 DCL - Data Control Language
Command Description Command Description
• SELECT Retrieves certain records from • GRANT Gives a privilege to user
one or more tables
• REVOKE Takes back privileges granted from user
• INSERT Creates a record

• UPDATE Modifies records

• DELETE Deletes records

You might also like