Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    Index su 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

  2. #2

    ...........

    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

  3. #3

    ................

    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

  4. #4

    Re: Index su foreign key ............

    Originariamente inviato da whisher
    Ciao.
    Volevo conoscere la Vs. opinione riguardo
    l'indicizzazione della foreign key.
    E' buona regola indicizzare sempre una
    foreign key ?
    Non è questione di opinioni, in MySQL è obbligatorio l'indice su una chiave esterna
    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.
    Riguardo alla sintassi:
    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}]

  5. #5

    .........

    Dunque grazie molte per l'aiuto prima di tutto.
    Per la sintassi correggimi se sbaglio:
    FOREIGN KEY ( `cat_id` ) REFERENCES categories( `cat_id` ) ON DELETE CASCADE
    ON DELETE CASCADE si usa per l'integrità referenziale o risbaglio
    Ultima curiosità quando vado a fare export con phpMyAdmin
    trovo al posto di foreign key ................ questo:
    KEY `cat_id` (`cat_id`)
    è la stessa cosa ?
    Stammi benissimo.
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  6. #6

    Re: .........

    Originariamente inviato da whisher
    ON DELETE CASCADE si usa per l'integrità referenziale o risbaglio
    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
    Ultima curiosità quando vado a fare export con phpMyAdmin
    trovo al posto di foreign key ................ questo:

    è la stessa cosa ?
    KEY indica gli indici, sotto ai quali dovresti avere le diciture CONSTRAINT per le varie chiavi esterne.

  7. #7

    ...........

    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

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.