Query Decomposition[1]
Query Decomposition[1]
DECOMPOSITION
• Ayesha
• Minahil
• Areeba
• Eshwa
• Mahnoor
• Zainab
Lexical Analysis:
• This is the first part of query normalization, where the query is analyzed at the token
level.
• The SQL query is broken down into basic components (tokens) such as keywords
(SELECT, FROM, WHERE), identifiers (table names, column names), operators (=, AND,
OR), and literals (values like 'Sales', 50000).
• The lexical analyzer checks if these tokens conform to the language syntax rules,
ensuring that each component of the query is correctly identified and classified.
• After the query passes the lexical and syntactic analysis, the
next step is to transform the query into a normal form.
SELECT ENAME
FROM EMP, ASG
WHERE EMP. ENO = ASG.ENO AND
ASG. PNO = 'P1' AND
DUR = 12 OR DUR = 24
Semantically incorrect
• Checks whether the components contribute in any way to the
generation of the results.
• Only a subset of relational calculus queries can be tested for
correctness, i.e., those that do not contain disjunction and
negation.
• Typical data structures used to detect the semantically
incorrect queries are:
1. Conjunction graph (query graph)
2. Join graph
DISTRIBUTED DATABASE MANAGEMENT SYSTEM
ANALYSIS EXAMPLE
• Example: Consider a query:
• Query/connection graph
- Nodes represent operand or result relation
- Edge represents a join if both connected nodes represent an
operand relation, otherwise it is a projection
• Join graph
- a subgraph of the query graph that consider are only the joins
•Once the query graph is connected, the query is semantically
correct. DISTRIBUTED DATABASE MANAGEMENT SYSTEM
ANALYSIS EXAMPLE
• Example: Consider the following query and its query graph: