Divide-and-Conquer for Multi-Unit Queries Query Condition To decide whether a gi
ID: 3755803 • Letter: D
Question
Divide-and-Conquer for Multi-Unit Queries
Query Condition
To decide whether a given query requirement is single-unit or multi-unit, we need to find its query condition first. Query condition is the part of the query requirement that specifies what rows should be kept in the query result. In English grammar, this is often the adjective clause of a sentence. For example, if the query requirement is to find the names of the programs that are offered by departments whose IDs are ‘CS’ and ‘EE’, then the query condition is the underlined part of the sentence.
Note that when a query requirement does not have a query condition, it is a single-unit query.
Query: Find all faculty members who work for the department with ID 'CS'.
Does the query have a query condition? If yes, what is the query condition?
Answer:
Query: Find names and GPAs of all students.
Does the query have a query condition? If yes, what is the query condition?
Answer:
Query: For students majoring in the program with ID 'P000', return their names and GPAs.
Does the query have a query condition? If yes, what is the query condition?
Answer:
Explanation / Answer
Query: Find all faculty members who work for the department with ID 'CS'.
Does the query have a query condition? If yes, what is the query condition?
Answer: Yes, the query has a query condition that the department id should be 'CS'.
So if the DeptName is a column in Department then the condition will be like
DeptName = 'CS'
Query: Find names and GPAs of all students.
Does the query have a query condition? If yes, what is the query condition?
Answer: No there is no condition for this query because it is mentioned to get the names and GPA of all students.
Query: For students majoring in the program with ID 'P000', return their names and GPAs.
Does the query have a query condition? If yes, what is the query condition?
Answer: Yes, the query has a query condition that the names and GPAs of students whose program id with P000 should be returned. So the condition will be like
ProgId = 'P000'.
Please check the code. If you have any doubts comment below and i am happy to help :)