The Following Steps May Be Helpful in Formulating the Query for the Problem

The Following Steps May Be Helpful in Formulating the Query for the Problem

<p>[QueryID:18]Give all pizzas that originate from the same country as the 'siciliano' pizza. The following steps may be helpful in formulating the query for the problem: Two ways to solve this problem:</p><p>Option 1: using a subquery</p><p>1. Mapping the data items required to the column names in the DB pizza name  pizza</p><p>2. Interpret the row selection condition  Pizza that originates from the same country as the ‘siciliano’ pizza  country = the country of the siciliano pizza and pizza <> siciliano</p><p>Note: “The country of origin of the ‘siciliano’ pizza” can be obtained by a subquery, which produces the country of origin of the ‘siciliano’ pizza. In order to form a logical expression using the subquery, use “=” to link the subquery as country = (subquery)</p><p> i. Mapping the data items required to the column names in the DB country of origin  country</p><p> ii. Interpret the row selection condition  Siciliano pizza  pizza = siciliano</p><p> iii. Identify the table(s) needed, which contains all the data items used in 1) and 2) menu table</p><p> iv. Group result or individual result No aggregate function is used  individual result, Group By is not needed. </p><p> v. Using the template: SELECT <list of columns or expressions > FROM <list of tables or join operations> WHERE <row selection condition ></p><p>3. Identify the table(s) needed, which contains all the data items used in 1) and 2) menu table 4. Group result or individual result No aggregate function is used  individual result, Group By is not needed. </p><p>5. Using the template: SELECT <list of columns or expressions > FROM <list of tables or join operations> WHERE <row selection condition including subquery></p><p>©H.Y Lu 2008 Option 2: -- using join</p><p>Consider two copies of the menu table, the first copy (m1) is for the selection pool of pizzas and the second one (m2) is for the siciliano pizza m2.pizza = siciliano</p><p>1. Mapping the data items required to the column names in the DB pizza name  pizza</p><p>2. Interpret the row selection condition  Pizza that originates from the same country as the ‘siciliano’ pizza  joining the two copies of the menu table based on the equality of country, and set row selection condition as m1.pizza <> siciliano and m2.pizza = siciliano</p><p>3. Identify the table(s) needed, which contains all the data items used in 1) and 2) menu m1 table and menu m2 table</p><p>4. How to join these two copies of menu table</p><p>Joining condition— m1.country = m2.country</p><p>Joining styles – in FROM, menu m1 join menu m2 on m1.country = m2.country or -- in FROM, menu m1, menu m2 and in WHERE, m1.country = m2.country </p><p>5. Group result or individual result No aggregate function is used  individual result, Group By is not needed. </p><p>6. Using the template: SELECT <list of columns or expressions > FROM <list of tables or join operations> WHERE <row selection condition ></p><p>©H.Y Lu 2008</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us