added tasks 6.1

This commit is contained in:
Sven Vogel 2023-11-03 12:36:40 +01:00
parent 11d76cae66
commit 7b08ad389b
3 changed files with 59 additions and 0 deletions

26
tasks/task-6-1-2.sql Normal file
View File

@ -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';

15
tasks/task-6-1-3.sql Normal file
View File

@ -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';

18
tasks/task-6-1-4.sql Normal file
View File

@ -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';