Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

null_questions?

FidelieFidelie Member Posts: 32
helo,
i make InnoDB tables in mysql.
I notice that it is possible to add rows where the foreign key is null!!
should this be possible?
however it is not possible to add rows with a foreeign key other then null that does not match any entri in the dad-table.
do u have to type not null so that u cant add entries that has no corresponding dad-entri in the dad-table?
i thought "foreign key references bla bla" should do this for u?
thank you very much
/fidelie


Comments

  • JonathanJonathan Member Posts: 2,914
    : i make InnoDB tables in mysql.
    ...and I make myISAM ones. I keep thinking about using InnoDB ones, though.

    : I notice that it is possible to add rows where the foreign key is
    : null!!
    : should this be possible?
    : however it is not possible to add rows with a foreeign key other
    : then null that does not match any entri in the dad-table.
    : do u have to type not null so that u cant add entries that has no
    : corresponding dad-entri in the dad-table?
    Yes, that's correct.

    : i thought "foreign key references bla bla" should do this for u?
    I guess it could be argued either way. There may be cases perhaps when you want records that will not have a reference to another one. MySQL is flexible in that it allows you to have that behaviour if you want it, but allows you also to use NOT NULL if you do not want it. Flexibility is a good thing, IMHO.

    Hope this helps,

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.