MySQL Forums
Forum List  »  Italian

Foreign keys
Posted by: loris grifa
Date: October 08, 2007 08:18AM

Salve a tutti. Alla mail che precedentemente h mandato non ha risposto nessuno...comunque, ci riprovo. Continuo ad avere problemi con le chiavi esterne. precisamente:
ho sviluppato l'entità INDIRIZZO:

create table INDIRIZZO (

MATR_IND char (6) primary key,
NOME varchar (60) NOT NULL,
CIVICO INTEGER unsigned NOT NULL,
UNIQUE (NOME, CIVICO)
)
E sto provando a creare una chiave esterna nell'entità LOCALE così definita:

create table LOCALE (

MATRICOLA char(6) primary key,
INDIRIZZO char(6) NOT NULL,
NOME varchar(30) NOT NULL,
TIPO ENUM( ‘1’, ‘2’, ‘3’, ‘4’, ‘5’) NOT NULL,
LIV ENUM( ‘01’, ‘02’, ‘03’ ) NOT NULL
DESCR varchar(160) ,
H_AP varchar(30) NOT NULL ,
TEL varchar(30) ,
G_CH varchar(15) DEFAULT ‘DOMENICA’,
TIPO_CUC varchar(30) DEFAULT ‘ITALIANA’ ,
MENU’ char(6) NOT NULL
OFFERTA char(6)
)
Tramite i comenadi:

alter table LOCALE add foreign key(INDIRIZZO) references INDIRIZZO(IND)
ON UPDATE CASCADE ON DELETE NO ACTION;
alter table LOCALE add foreign key(LIV) references....

l'errore che mi da è il seguente:
ERROR 1452 (23000): cannot add or update a child row : a foreign key constraint fails ('ristorante/#sql-424_1', constraint'#sql-424_1_ibfk_3'foreign key(INDIRIZZO) references INDIRIZZO(IND)
ON UPDATE CASCADE ON DELETE NO ACTION

Vi ringrazio della collaborazione e aspetto notizie

Options: ReplyQuote


Subject
Views
Written By
Posted
Foreign keys
9908
October 08, 2007 08:18AM
3627
October 19, 2007 04:53AM
3419
November 16, 2007 12:32PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.