Maybe this could be a stupid question. Ok, so I created the following table:
create table USER(
ID int NOT NULL AUTO_INCREMENT primary key,
firstname varchar(50) not null,
lastname varchar(50) not null,
password varchar(20) not null,
emailU varchar(100) not null
);
create table POST(
ID_User int,
ID_Tweet int,
primary key(ID_User, ID_Tweet),
foreign key(ID_User) references USER(ID) on update cascade on delete cascade,
foreign key(ID_Tweet) references TWEET(ID) on update cascade on delete cascade
);
create table TWEET(
ID int NOT NULL AUTO_INCREMENT primary key,
Text varchar(200)
);
When I insert something, for example:
insert into USER (firstname, lastname, password, emailU) values ('X', 'Y', 'XY', 'xy@gmail.com');
and
insert into TWEET (text) values ('Something');
It updates correctly the tables USER and TWEET, but the table POST remains empty. Why? It should be updated with the ID_User and ID_Tweet or I get wrong?