zad1
1 CREATE TABLE `szkola_dm`.`gracze` (`Id_u` SMALLINT(5) UNSIGNED NOT NULL , `Imie` VARCHAR(15) NOT NULL , `Nazwisko` VARCHAR(15) NOT NULL , `id_d` INT NULL ) ENGINE = InnoDB;
2 CREATE TABLE `szkola_dm`.`trenerzy` (`Id_tr` TINYINT(4) NOT NULL , `Imie` VARCHAR(15) NOT NULL , `Nazwisko` VARCHAR(15) NOT NULL , `Kraj` VARCHAR(10) NOT NULL ) ENGINE = InnoDB;
3 CREATE TABLE `szkola_dm`.`druzyny` (`Id_d` SMALLINT(5) UNSIGNED NOT NULL , `Nazwa` VARCHAR(15) NOT NULL , `Id_tr` INT NOT NULL , `Data_pow` DATE NOT NULL ) ENGINE = InnoDB;
zad2


1 ALTER TABLE `druzyny` ADD PRIMARY KEY(`Id_d`); 
2 ALTER TABLE `gracze` ADD PRIMARY KEY(`Id_u`); 
3 ALTER TABLE `trenerzy` ADD PRIMARY KEY(`Id_tr`); 

4 ALTER TABLE `gracze` ADD INDEX(`id_d`); 
5 ALTER TABLE `druzyny` ADD INDEX(`Id_tr`);

 
zad3

ALTER TABLE `gracze` ADD FOREIGN KEY (`id_d`) REFERENCES `druzyny`(`Id_d`) ON DELETE SET NULL ON UPDATE CASCADE;
 
 
zad4--
ALTER TABLE `druzyny` ADD FOREIGN KEY (`Id_tr`) REFERENCES `trenerzy`(`Id_tr`) ON DELETE RESTRICT ON UPDATE SET NULL;
zad5

INSERT INTO `druzyny` (`id_d`, `Nazwa`, `id_tr`, `Data_pow`) VALUES ('4', 'SKRA', NULL, '1930-09-02'), ('7', 'ZAKSA', NULL, '1994-03-08'); 
zad6
update gracze set imie='Jakub' where imie='Kuba' and id_d=4; 