added tasks 6.1
This commit is contained in:
parent
11d76cae66
commit
7b08ad389b
|
@ -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';
|
|
@ -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';
|
|
@ -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';
|
Loading…
Reference in New Issue