mysql - Can the field type of a foreign key be different to the referenced primary key? -


i e-r model not designed me. have no way contact author. there confusing me in model. in table a, primary key integer field. table b has foreign key referenced pk of a. fk of b varchar field. start learning database dedign, , never see or in jobs. reasonable , realizable? note model mysql.

that can't implemented foreign key constraint in innodb; datatype of foreign key column(s) must match datatypes of referenced column(s) exactly.

you can perform join operation on columns, although there's going need datatype conversion on 1 side or other... e.g.

on c.character_col + 0 = p.numeric_col 

it's permissible in sql; don't have have foreign key constraint defined in order perform join operations.

this design not 1 see; 1 of big issues performance, in mysql can't make effective use of index on character_col.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -