Unsupported Screen Size: The viewport size is too small for the theme to render properly.

Same Problem On Foreign Key

forums forums SQLyog Using SQLyog Same Problem On Foreign Key

  • This topic is empty.
Viewing 1 reply thread
  • Author
    Posts
    • #20197
      peterlaursen
      Participant

      well .. this is basically how a Foreign Key is supposed to work! A Foreign Key also is a CONSTRAINT. Data in the child table are constrainted to/restricted to being valid with data in the parent table.

      A Foreign Key is an index where the index in being built with data from another table – You cannot use a NULL value is an Foreign Key. Also NULL is nothing – it is not zero! That is why you get the error 'Can't update …' – because there is nothing (that is what NULL means) to update with.

      Further you define genre_id SMALLINT NOT NULL PRIMARY KEY and write and i leave the field genre_id blank (it can be null). Is not that a contracition?

      I believe that you must define a certain value for album_id, artist_id and genre_id having the meaning of 'unknown/undecided'. That can be O (zero) -1 or anything.

      I also hope you understand that the question(s) you are asking are not SQLyog-related questions – but general MySQL/database design/SQL questions. As such they should probably have been in 'MySQL Server' category. Just for perfectness! But that is OK 🙂

      However there a other places to ask database design questions where you will probably get more response.

      However Cal is here now I see …

    • #20198
      Luc_40
      Member
      peterlaursen wrote on Jan 10 2006, 02:41 PM:
      Further you define genre_id SMALLINT NOT NULL PRIMARY KEY and write and i leave the field genre_id blank (it can be null).  Is not that a contracition?

      I meant the field genre_id in the table tracks, there it is said to be null allowed.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.