1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mindblock: SQL and normalisation

Discussion in 'HTML, Graphics & Programming' started by SiD the Turtle, 28 Jul 2006.

  1. SiD the Turtle

    Sgarrista

    Joined: 16 Nov 2003

    Posts: 9,695

    Location: On the pale blue dot

    I must not be getting something. Can you at least 2NF data in SQL?

    For example if I have a table with elements A, B and C, a column in another table should only let you select one of these elements. Is it a case of just enforcing this through the input method (i.e. in the webform have a drop down box populated by the first table rather than a input field) or is there a way to link elements within SQL.

    I am using MySQL at the moment.
     
  2. ByteJuggler

    Hitman

    Joined: 5 Jun 2005

    Posts: 988

    Location: Leicestershire

    Data in tables can be said to either be or not be in 2nd normal form depending on how the fields in the tables are related to their corresponding primary keys and each other. Seperately/Apart from this, is the issue of referential integrity, which can be implemented via SQL if the underlying database engine supports it (i.e. you need to set up a foreign key contraint on the field in the "other" table so it references the table where A, B and C are primary key values. )
     
  3. SiD the Turtle

    Sgarrista

    Joined: 16 Nov 2003

    Posts: 9,695

    Location: On the pale blue dot

    Ah ha! Foriegn keys! That's what I was trying to think of. Thanks for that.