SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm currently working on a database with several tables.
    In most tables I have 'UserID' as a foreign key to an 'employee' table.

    I would like to make a 'foreign key'-relationship between the other tables and the table 'employee'. I would also like to implement 'cascade' rules.

    Could someone tell me if this is possible with MySQL... and if so, how to do it within phpMyAdmin.

    sincerely,

    Jasper

  2. #2
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mySQL doesn't contain support for foreign key constraints unfortunately - it's one of the things on their infamous "TODO" list.

  3. #3
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    At this stage MySQL does not support foreign keys - cascading updates and deletes. I know its high on the to do list - so one day soon hopefully. This is quite tragic really isn't it? Its what stops mysql from being a true RDMS.

    <<edited>>

    SNAP Skunk!

  4. #4
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MySQL as freakysid mentions does not support foreign keys, but unless you intend to do all of your db access via phpMyAdmin, it only takes a few moments to 'code in' your own constraints, i.e any php/whatever script that updates a table just has to check what effects this has elsewhere in the structure, the difference being that you the programmer have the constraints in your head, and not dictated to you.

    It also allows the flexibility to 'bend the rules' in certain circumstances which foreign keys do not allow.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •