Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
modul:m290:learningunits:lu04:loesungen:l02 [2024/09/03 14:36] – angelegt vdemir | modul:m290:learningunits:lu04:loesungen:l02 [2024/10/17 12:35] (aktuell) – vdemir | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== | + | ====== |
- | + | ||
- | ===== Requirements | + | |
- | * Work type: individual | + | |
- | * Timeframe: 30 Minutes | + | |
- | * Means of aid: | + | |
- | * only teaching materials, no websearch, no use of ai. | + | |
- | * [[https:// | + | |
- | * Expected result: Semantically and syntactically correct SQL statements according to the requirements of the case studies. | + | |
Zeile 16: | Zeile 8: | ||
===== Assignments ===== | ===== Assignments ===== | ||
- | You general assignment is to develop DQL commands that matches the requirements below: | + | The general assignment is to develop DQL commands that matches the requirements below: |
- | * a) Supplier and PrWe need a list with product details as following: | + | ==== Assignment A ==== |
- | * Supplier name | + | We need a list with product details as following: |
- | * Supplier phone | + | |
- | * ProductID | + | |
- | * ProductName | + | |
- | * Units | + | |
- | * Price | + | |
- | * Ordered | + | |
SELECT s.SupplierName, | SELECT s.SupplierName, | ||
Zeile 32: | Zeile 18: | ||
ORDER BY s.SupplierName DESC; | ORDER BY s.SupplierName DESC; | ||
- | * b) Extend the select, so that the list contains | + | ==== Assignment B ==== |
- | | + | Extend the the result of the Select statement from assignment a), so that it must contain |
- | * b1) The first one is to to search for the ID (SupplierID = 20) of the supplier and take that ID into our SELECT as follows: | + | |
+ | There are two possible solutions. | ||
+ | |||
+ | **B1)** | ||
+ | The first assignment | ||
SELECT s.SupplierName, | SELECT s.SupplierName, | ||
Zeile 41: | Zeile 31: | ||
AND s.SupplierID = 20; | AND s.SupplierID = 20; | ||
- | | + | **B2)** |
+ | The second solution | ||
SELECT s.SupplierName, | SELECT s.SupplierName, | ||
Zeile 47: | Zeile 38: | ||
WHERE p.SupplierID = s.SupplierID | WHERE p.SupplierID = s.SupplierID | ||
AND s.SupplierName = 'Leka Trading'; | AND s.SupplierName = 'Leka Trading'; | ||
+ | | ||
The result set is in both cases, as the figure below shows: | The result set is in both cases, as the figure below shows: | ||
{{: | {{: | ||
| | ||
- | * c) We would like to know what products the customer " | + | ==== Assigmment C ==== |
- | * In detail we require the following data: CustomerID, CustomerName, | + | We would like to know what products the customer " |
- | | + | **C1)** |
+ | Like in assignment b) here a two approaches possible: 1. find the customerID (34) and select according to the customer id. | ||
- | | + | |
FROM customers c, orders o, OrderDetails od, Products p, Categories ct | FROM customers c, orders o, OrderDetails od, Products p, Categories ct | ||
WHERE c.CustomerID = o.CustomerID | WHERE c.CustomerID = o.CustomerID | ||
Zeile 67: | Zeile 58: | ||
ORDER BY od.Quantity; | ORDER BY od.Quantity; | ||
- | | + | **C2)** |
+ | The second approach, as in B2), is to filter the result set directly by customer name. | ||
- | | + | |
FROM customers c, orders o, OrderDetails od, Products p, Categories ct | FROM customers c, orders o, OrderDetails od, Products p, Categories ct | ||
WHERE c.CustomerID = o.CustomerID | WHERE c.CustomerID = o.CustomerID | ||
Zeile 75: | Zeile 67: | ||
AND od.ProductID = p.ProductID | AND od.ProductID = p.ProductID | ||
AND p.CategoryID = ct.CategoryID | AND p.CategoryID = ct.CategoryID | ||
- | AND c.CustomerName = " | + | AND c.CustomerName = " |
ORDER BY od.Quantity; | ORDER BY od.Quantity; | ||
| | ||
- | | + | The result set is in both cases as shown in the following figure. |
| | ||
{{: | {{: | ||
| | ||
===== Solution ===== | ===== Solution ===== | ||
- | [[modul: | + | [[modul: |