Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    78

    Unanswered: is this a legal operation?

    hi in the following table i have 2 foriegn key which reference to a different table, is this the way i would show this.?


    CREATE TABLE Car_stats
    (
    VehReg VARCHAR(10) NOT NULL,
    Model VARCHAR(40) NOT NULL,
    Make VARCHAR(55) NOT NULL,
    Colour VARCHAR(30) NOT NULL,
    Millage INT NOT NULL,
    MOT_Due_Date TIMESTAMP(6) NOT NULL,
    PRIMARY KEY (VehReg),

    CONSTRAINT statmodel_fk FOREIGN KEY (Model) REFERENCES Car_type (Model),
    CONSTRAINT statmake_fk FOREIGN KEY (Make) REFERENCES Car_type (Make)
    );

  2. #2
    Join Date
    Jan 2003
    Location
    Paris, France
    Posts
    320
    You forget to create index for you col ref

    You will get a 150 error if you use INNODB table type
    Olivier Miossec
    --
    http://www.lasso-developpeur.net/
    --

  3. #3
    Join Date
    Feb 2004
    Posts
    78
    how would i do that?

  4. #4
    Join Date
    Feb 2004
    Posts
    78
    would it be okay to do this instead?

    CREATE TABLE Car_stats
    (
    VehReg VARCHAR(10) NOT NULL,
    Model VARCHAR(40) NOT NULL,
    Make VARCHAR(55) NOT NULL,
    Colour VARCHAR(30) NOT NULL,
    Millage INT NOT NULL,
    MOT_Due_Date TIMESTAMP(6) NOT NULL,
    PRIMARY KEY (VehReg),

    CONSTRAINT statmodel_fk FOREIGN KEY (Model,Make) REFERENCES Car_type (Model,Make)

    );

Posting Permissions

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