-- Prihlasit se jako root, prazdne heslo
CREATE USER  'student'@'localhost'   IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO   'student'@'%'   IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO   'student'@'localhost'   IDENTIFIED BY 'password';


-- Prihlasit se jako student, heslo password
CREATE DATABASE DailyPlanet
    CHARACTER SET utf8mb4
    COLLATE utf8mb4_czech_ci;

USE DailyPlanet;

CREATE TABLE Autor (
    Autor_ID CHAR(36) PRIMARY KEY NOT NULL,
    KrestniJmeno VARCHAR(250),
    Prijmeni VARCHAR(250),
    Email VARCHAR(250),
    Telefon VARCHAR(32)
) ENGINE=INNODB;

CREATE TABLE Clanek (
    Clanek_ID CHAR(36) PRIMARY KEY NOT NULL,
    Nazev VARCHAR(250) NOT NULL,
    Autor_ID CHAR(36) ,
    Cislo_revize INT DEFAULT 0,
    FOREIGN KEY (Autor_ID) REFERENCES Autor(Autor_ID) ON DELETE CASCADE
) ENGINE=INNODB;


INSERT INTO Autor (Autor_ID, KrestniJmeno, Prijmeni, Email, Telefon) VALUES ('c705ef4e-5de0-4409-b537-957605df610c', 'Clark', 'Kent', 'clark.kent@dailyplanet.com', '+14155552671');
INSERT INTO Autor (Autor_ID, KrestniJmeno, Prijmeni, Email, Telefon) VALUES ('258c5ea5-ce1c-4433-99e6-2fd58557ef21', 'Loise', 'Lane', 'loise.lane@dailyplanet.com', '+14154641123');
INSERT INTO Autor (Autor_ID, KrestniJmeno, Prijmeni, Email, Telefon) VALUES ('7d92828e-5b8a-43d4-a9ce-7fcf02778950', 'Jimmy', 'Olsen', 'jimmy.olsen@dailyplanet.com', '+14153343321');
INSERT INTO Autor (Autor_ID, KrestniJmeno, Prijmeni, Email, Telefon) VALUES ('5d35d75b-892b-4f14-be3c-f8964369d6a2', 'Perry', 'White', 'perry.white@dailyplanet.com', '+14253442888');
INSERT INTO Autor (Autor_ID, KrestniJmeno, Prijmeni, Email, Telefon) VALUES ('99ea7420-825e-4973-b697-e8a49267b121', 'Cat', 'Grant', 'cat.grant@dailyplanet.com', '+14259990001');

INSERT INTO Clanek (Clanek_ID, Nazev, Autor_ID, Cislo_revize) VALUES ('8ac75dbb-0f6f-4953-b35d-151f04ce1d09', 'Nejstarší ženou na světě je Jamaičanka', '258c5ea5-ce1c-4433-99e6-2fd58557ef21', 10);
INSERT INTO Clanek (Clanek_ID, Nazev, Autor_ID, Cislo_revize) VALUES ('15514d7c-12ab-4540-ba6d-f8e155952bb9', 'Řidič naboural do policejního auta', 'c705ef4e-5de0-4409-b537-957605df610c', 5);
INSERT INTO Clanek (Clanek_ID, Nazev, Autor_ID, Cislo_revize) VALUES ('bca72825-31c8-42e8-b7e6-2d9d9252c1a4', 'Výpadky elektřiny kvůli počasí', '7d92828e-5b8a-43d4-a9ce-7fcf02778950', 2);



