Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2001
    Location
    South Africa
    Posts
    33

    Unanswered: table schema and foreign keys ?

    HI,

    I want to create 3 innodb tables that are all linke via foreign keys :

    CREATE TABLE ccd_details (
    uid int(11) NOT NULL default '0',
    ccd int(11) NOT NULL default '0',
    cvv int(11) NOT NULL default '0'
    PRIMARY KEY ('uid')
    ) TYPE=InnoDB;

    CREATE TABLE pin_details (
    uid int(11) NOT NULL default '0',
    pid int(11) NOT NULL default '0'
    PRIMARY KEY ('uid')
    ) TYPE=InnoDB;


    CREATE TABLE user_details (
    uid int(11) NOT NULL default '0',
    username varchar(16) NOT NULL default '',
    password varchar(16) NOT NULL default ''
    PRIMARY KEY ('uid')
    ) TYPE=InnoDB;


    all tables need to be linked via foreign keys ?? Is this possible ?
    Can the uid on user_details be autoincrementing and have a foreign key ??

    Many thanks for the help :)

  2. #2
    Join Date
    May 2003
    Location
    Sweden
    Posts
    3
    up

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you can declare the auto_increment property for any numeric field, i believe

    can the uid on user_details have a foreign key? if you mean, can some other table have a foreign key that references the primary key uid in user_details, the answer is yes, even if it's an auto_increment

    in other words, if user_details is the main table, and ccd_details and pin_details are related to user_details, then the uid primary keys of ccd_details and pin_details would each also be a foreign key referencing user_details

    rudy
    http://r937.com/

Posting Permissions

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