aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerghei Cebotari <serghei@cebotari.ru>2023-11-14 12:00:03 +0300
committerSerghei Cebotari <serghei@cebotari.ru>2023-11-14 12:00:03 +0300
commitd3c17493608f1657c490fb8cbe1f6ba427140137 (patch)
tree8779e979e135cba70d3954d3a04c8c73e1c4c17f
parent43be957b9318b2ab6ce43bbb06a0a90748351d68 (diff)
Add README
-rw-r--r--README.md51
1 files changed, 51 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b418d4f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,51 @@
+## База данных
+### Таблица со списком категорий
+```sql
+CREATE TABLE categories(
+ category_id INT NOT NULL PRIMARY KEY,
+ category_name VARCHAR(10)
+);
+```
+### Таблица со списком продуктов
+```sql
+CREATE TABLE products(
+ product_id INT NOT NULL PRIMARY KEY,
+ product_name VARCHAR(10)
+);
+```
+### Таблица товара с категориями
+```sql
+CREATE TABLE grocery_store(
+ product_id INT,
+ category_id INT,
+ FOREIGN KEY (product_id) REFERENCES products (product_id),
+ FOREIGN KEY (category_id) REFERENCES categories (category_id)
+);
+```
+## Выбор всех пар "Имя продукта - Имя категории" (основное задание)
+Запрос
+```sql
+SELECT product_name AS product, category_name AS category FROM products
+LEFT JOIN grocery_store ON grocery_store.product_id = products.product_id
+LEFT JOIN categories ON grocery_store.category_id = categories.category_id
+ORDER BY product;
+```
+
+
+```ps
+Invoke-RestMethod https://mindbox.cebotari.ru/item -Method GET
+```
+
+## Дополнительно реализованы
+### Добавление новой категории
+```ps
+Invoke-RestMethod https://mindbox.cebotari.ru/category -Method POST -Body (@{Id=5; Name="Black"} | ConvertTo-Json) -ContentType "application/json"
+```
+### Добавление нового продукта
+```ps
+Invoke-RestMethod http://mindbox.cebotari.ru/product -Method POST -Body (@{Id=5; Name="Olives"} | ConvertTo-Json) -ContentType "application/json"
+```
+### Добавление новой нового товара
+```ps
+Invoke-RestMethod -Uri "http://mindbox.cebotari.ru/item?productId=5&categoryId=5" -Method POST
+``` \ No newline at end of file