Hello, I am trying to create the following table
create table messaInScena
(
data date,
ora time,
spazio varchar(20),
spettacolo varchar(40),
postiDisponibili smallint,
prezzoIntero decimal(5,2),
prezzoRidotto decimal(5,2),
prezzoStudenti decimal(5,2),
primary key (data, ora, spazio),
foreign key (spazio) references spazio(nome) on update cascade on delete set null,
foreign key (spettacolo) references spettacolo(titolo) on update cascade on delete set null,
constraint RA3_1 check (postiDisponibili >= 0)
) ;
but I get the following error:
Error Code: 1005 Can not create table 'teatrosql.messainscena' (errno: 150)
The tables that are referenced by foreign keys are:
create table spazio
(
nome varchar(20) primary key,
indirizzo varchar(40) not null,
pianta varchar(20),
capienza smallint
);
create table spettacolo
(
titolo varchar(40) primary key,
descrizione LONGBLOB,
annoProduzione char(4)
);
I have already verified that the fk are unique and that there are no typos (but given a control also you that you never know :D). As you can see the reference fields are primary keys. between fields and fk reference types and dimensions coincide ..
where am I wrong??
ps. if you need to place all the tables
create table messaInScena
(
data date,
ora time,
spazio varchar(20),
spettacolo varchar(40),
postiDisponibili smallint,
prezzoIntero decimal(5,2),
prezzoRidotto decimal(5,2),
prezzoStudenti decimal(5,2),
primary key (data, ora, spazio),
foreign key (spazio) references spazio(nome) on update cascade on delete set null,
foreign key (spettacolo) references spettacolo(titolo) on update cascade on delete set null,
constraint RA3_1 check (postiDisponibili >= 0)
) ;
but I get the following error:
Error Code: 1005 Can not create table 'teatrosql.messainscena' (errno: 150)
The tables that are referenced by foreign keys are:
create table spazio
(
nome varchar(20) primary key,
indirizzo varchar(40) not null,
pianta varchar(20),
capienza smallint
);
create table spettacolo
(
titolo varchar(40) primary key,
descrizione LONGBLOB,
annoProduzione char(4)
);
I have already verified that the fk are unique and that there are no typos (but given a control also you that you never know :D). As you can see the reference fields are primary keys. between fields and fk reference types and dimensions coincide ..
where am I wrong??
ps. if you need to place all the tables