From 7b08ad389bbf18afe5d543d1264d026b54b22d8c Mon Sep 17 00:00:00 2001 From: servostar Date: Fri, 3 Nov 2023 12:36:40 +0100 Subject: [PATCH] added tasks 6.1 --- tasks/task-6-1-2.sql | 26 ++++++++++++++++++++++++++ tasks/task-6-1-3.sql | 15 +++++++++++++++ tasks/task-6-1-4.sql | 18 ++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 tasks/task-6-1-2.sql create mode 100644 tasks/task-6-1-3.sql create mode 100644 tasks/task-6-1-4.sql diff --git a/tasks/task-6-1-2.sql b/tasks/task-6-1-2.sql new file mode 100644 index 0000000..143a372 --- /dev/null +++ b/tasks/task-6-1-2.sql @@ -0,0 +1,26 @@ +CREATE SCHEMA shirt_shop; + +CREATE TABLE shirt_shop.shirts ( + name VARCHAR(40) NOT NULL PRIMARY KEY , + size ENUM('small', 'medium', 'large') NOT NULL, + color SET('blue', 'black', 'white') NOT NULL +); + +INSERT INTO shirt_shop.shirts SET + name = 'large dress shirt', + size = 'large', + color = 'black'; + + +INSERT INTO shirt_shop.shirts SET + name = 'medium t-shirt', + size = 'medium', + color = 'white,blue'; + + +INSERT INTO shirt_shop.shirts SET + name = 'small polo shirt', + size = 'small', + color = 'blue'; + +SELECT name, color FROM shirt_shop.shirts WHERE color = 'black' AND size = 'large'; \ No newline at end of file diff --git a/tasks/task-6-1-3.sql b/tasks/task-6-1-3.sql new file mode 100644 index 0000000..51d760c --- /dev/null +++ b/tasks/task-6-1-3.sql @@ -0,0 +1,15 @@ +CREATE SCHEMA luxury_shirts; + +CREATE TABLE luxury_shirts.LuxuryShirt ( + uuid BINARY(16) NOT NULL, + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + typ VARCHAR(26) NOT NULL , + product_line VARCHAR(26) NOT NULL , + customer VARCHAR(40) NOT NULL +); + +INSERT INTO luxury_shirts.LuxuryShirt SET + uuid = UUID_TO_BIN(UUID()), + typ = 'small polo shirt', + product_line = 'NoblesseOblige', + customer = 'Hans Dampf'; \ No newline at end of file diff --git a/tasks/task-6-1-4.sql b/tasks/task-6-1-4.sql new file mode 100644 index 0000000..ccb1a25 --- /dev/null +++ b/tasks/task-6-1-4.sql @@ -0,0 +1,18 @@ +CREATE SCHEMA luxury_shirts; + +CREATE TABLE luxury_shirts.LuxuryShirtWithForeignKey ( + uuid BINARY(16) NOT NULL, + id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, + typ VARCHAR(40) NOT NULL, + product_line VARCHAR(26) NOT NULL , + customer VARCHAR(40) NOT NULL, + FOREIGN KEY (typ) REFERENCES shirt_shop.shirts(name) +); + +INSERT INTO luxury_shirts.LuxuryShirtWithForeignKey SET + uuid = UUID_TO_BIN(UUID()), + typ = 'small polo shirt', + product_line = 'NoblesseOblige', + customer = 'Hans Dampf'; + +SELECT * FROM luxury_shirts.LuxuryShirtWithForeignKey INNER JOIN shirt_shop.shirts ON LuxuryShirtWithForeignKey.typ = shirts.name WHERE color = 'blue'; \ No newline at end of file