Ciao.
Volevo conoscere la Vs. opinione riguardo
l'indicizzazione della foreign key.
E' buona regola indicizzare sempre una
foreign key ?
![]()
Ciao.
Volevo conoscere la Vs. opinione riguardo
l'indicizzazione della foreign key.
E' buona regola indicizzare sempre una
foreign key ?
![]()
Without faith, nothing is possible. With it, nothing is impossible
http://ilwebdifabio.it
Ah dato che ci siamo
Che differenza c'è tra
INDEX e KEY è una sintassi
alternativa o cambia qc anche
a livello di struttura dati ?
E' preferibile segnalare a MYSQL
una cosa del genere:
FOREIGN KEY (`cat_id`) references categories (`cat_id`),![]()
Without faith, nothing is possible. With it, nothing is impossible
http://ilwebdifabio.it
Non c'è proprio nessuno
in vena di dire il suo autorevole
parere !![]()
Without faith, nothing is possible. With it, nothing is impossible
http://ilwebdifabio.it
Non è questione di opinioni, in MySQL è obbligatorio l'indice su una chiave esternaOriginariamente inviato da whisher
Ciao.
Volevo conoscere la Vs. opinione riguardo
l'indicizzazione della foreign key.
E' buona regola indicizzare sempre una
foreign key ?
![]()
Riguardo alla sintassi:In the referencing table, there must be an index where the foreign key columns are listed as the first columns in the same order. Starting with MySQL/InnoDB 4.1.2, such an index will be created on the referencing table automatically if it does not exist.
In the referenced table, there must be an index where the referenced columns are listed as the first columns in the same order.
codice:[CONSTRAINT symbol] FOREIGN KEY [id] (index_col_name, ...) REFERENCES tbl_name (index_col_name, ...) [ON DELETE {RESTRICT | CASCADE | SET NULL | NO ACTION}] [ON UPDATE {RESTRICT | CASCADE | SET NULL | NO ACTION}]
Dunque grazie molte per l'aiuto prima di tutto.
Per la sintassi correggimi se sbaglio:
ON DELETE CASCADE si usa per l'integrità referenziale o risbaglioFOREIGN KEY ( `cat_id` ) REFERENCES categories( `cat_id` ) ON DELETE CASCADE
Ultima curiosità quando vado a fare export con phpMyAdmin
trovo al posto di foreign key ................ questo:
è la stessa cosa ?KEY `cat_id` (`cat_id`)
Stammi benissimo.
![]()
Without faith, nothing is possible. With it, nothing is impossible
http://ilwebdifabio.it
Sì, ma non è l'unica opzione che puoi usare. Dipende dalla logica con cui hai progettato il tutto, in alcuni casi va bene il delete, in altri puoi preferire un'altra azione.Originariamente inviato da whisher
ON DELETE CASCADE si usa per l'integrità referenziale o risbaglio![]()
KEY indica gli indici, sotto ai quali dovresti avere le diciture CONSTRAINT per le varie chiavi esterne.Originariamente inviato da whisher
Ultima curiosità quando vado a fare export con phpMyAdmin
trovo al posto di foreign key ................ questo:
è la stessa cosa ?
Merci beaucoup à nouveau !![]()
Scusa il francese ma ho avuto una
giornataccia e questo post mi ha rimesso
di buonumore e il francese mi gasa !
Ok vado avanti con la baracca (sto
cercando di buttare giù un Db per un
forum ) approfondisco la cosa poi
magari con calma ti posto il tutto.
Consigli rimbrotti e miglioramenti sono
molto molto ben accetti.
![]()
Without faith, nothing is possible. With it, nothing is impossible
http://ilwebdifabio.it