By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE `compra` (
`idCompra` int(11) NOT NULL primary key,
`dataCompra` datetime DEFAULT NULL,
`valorTotal` varchar(50) DEFAULT NULL,
`utilizador_idUser` int(11) NOT NULL
);
CREATE TABLE `camisolas` (
`idCam` int(11) NOT NULL primary key,
`nome` varchar(100) NOT NULL,
`preco` float NOT NULL,
`camisola_imagem` varchar(150) NOT NULL
);
create table user_has_compra(
idCompra1 int primary key auto_increment,
idBuy int(11),
idCamisola int(11),
quantidade int(10)
);
ALTER TABLE `user_has_compra`
ADD CONSTRAINT `fk_compra_camisola` FOREIGN KEY (`idCamisola`) REFERENCES `camisolas` (`idCam`),
ADD CONSTRAINT `fk_compra_compra` FOREIGN KEY (`idBuy`) REFERENCES `compra` (`idCompra`)
;