Dicas para um iniciante em Java (era: Desenvolvimento)  XML
Índice dos Fóruns » Java Básico
Autor Mensagem
Mauricio Linhares
Moderador
[Avatar]

Membro desde: 09/01/2005 23:28:22
Mensagens: 3717
Localização: João Pessoa, Paraíba - Brasil
Offline

Leandro BSB wrote:

http://mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html

Foreign keys definitions are subject to the following conditions:

Both tables must be InnoDB tables and they must not be TEMPORARY tables.

In the referencing table, there must be an index where the foreign key columns are listed as the first columns in the same order. Such an index is 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.

Index prefixes on foreign key columns are not supported. One consequence of this is that BLOB and TEXT columns cannot be included in a foreign key, because indexes on those columns must always include a prefix length.



Restrições e complicações que não existem no PostgreSQL. Não estou dizendo que o PostgreSQL não tem nenhum problema, mas prefiro ele mesmo assim.

[]s

Leandro


Tem certeza?

Todas essas restrições também existem no PostgreSQL, já tentou referenciar como foreign key uma coluna que não tem índice?

Pois tente.

Existe essa explicação no MySQL porque ele tem vários modelos de armazenamento e alguns desses modelos não exigem integridade referencial, que é o caso das tabelas do tipo MyISAM. Agora, se você quer que o seu banco tenha integridade referêncial garantida, vai ter que utilizar o modelo de armazenamento InnoDB, que esse sim tem integridade referêncial.

O MySQL não obriga modelos que não precisam de integridade (ou que tem a integridade controlada pela aplicação) a ter integridade, pois tabelas sem integridade são muito mais rápidas do que tabelas comuns.
[WWW]
 
Índice dos Fóruns » Java Básico
Ir para:   
Powered by JForum 2.1.8 © JForum Team