Changes between Version 5 and Version 6 of Application Design – Use Cases and Database Access Scenarios – SQL View


Ignore:
Timestamp:
08/27/25 08:29:55 (7 days ago)
Author:
221531
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Application Design – Use Cases and Database Access Scenarios – SQL View

    v5 v6  
    194194\\
    195195==== Most important use cases
     1961. View My Food Orders
     197\\
     198This SQL statement selects the order_id, order_date, status, and the total price from the ''order'' table together with the ordered items from the ''order_items'' table and their names from the ''item'' table. A join is made between ''order_items'', ''item'', and ''order''. It filters only the orders of the user with user_id = 1 and displays them ordered by date (order_date) in descending order (newest first).
     199\\
     200{{{#!td
     201SELECT
     202    o.order_id, o.order_date, o.status,
     203    i.name AS item_name, oi.quantity, oi.total_price
     204FROM "ORDERS" o\\
     205JOIN ORDER_ITEMS oi ON o.order_id = oi.order_id\\
     206JOIN ITEM i ON oi.item_id = i.item_id\\
     207WHERE o.user_id = 1\\
     208ORDER BY o.order_date DESC;
     209}}}
     2102. Manage Restaurant's Menu
     211This SQL statement selects all items item_id, name, price and description of a given restaurant. A join is made between the ''menu'' table and the ''item'' table through item_id. It filters by restaurant_id = 2 to show only the menu for that restaurant.
     212
     213{{{#!td
     214SELECT
     215    i.item_id, i.name, i.price, i.description, i.image_url
     216FROM MENU m\\
     217JOIN ITEM i ON m.item_id = i.item_id\\
     218WHERE m.restaurant_id = 2\\
     219ORDER BY i.name ASC;\\
     220}}}
     2213. Track Order Status
     222This SQL statement selects the order_id, order_date, status, and the restaurant name from which the order was placed. A join is made between the ''order'', ''restaurant'', and ''restaurant_owners'' tables. It filters for the order with order_id = 1.
     223{{{#!td
     224SELECT
     225    o.order_id, o.order_date, o.status, r.name AS restaurant_name
     226FROM "ORDERS" o
     227JOIN RESTAURANT r ON o.address_id = r.address_id
     228JOIN RESTAURANT_OWNERS ro ON r.restaurant_id = ro.restaurant_id
     229WHERE o.order_id = 1;
     230
     231}}}