Multiple constraint for foreign keys in ms access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ikarusbliss
    New Member
    • Mar 2013
    • 1

    Multiple constraint for foreign keys in ms access

    Hi,

    I would like to form a table which needs to be connected with 2 other tables. I need to create 2 foreign keys for them. But there is an error pop out saying "There is an relationship named 'Avatar_fk' in the table". Did I make any mistake in the following SQL.

    Code:
    Create table Avatar 
    (
    	AvatarID varchar(100) NOT NULL,
    	AvatarName varchar(100),
    	Gender char(1),
    	DOB date,
    	AvatarStrengthIndicator int,
    	Hoard int,
    	SpeciesID varchar(100),
    	PlayerID varchar(100),
    Constraint Avatar_pk PRIMARY KEY (AvatarID),
    Constraint Avatar_fk FOREIGN KEY (PlayerID) REFERENCES Player (PlayerID)
    Constraint Avatar_fk FOREIGN KEY (SpeciesID) REFERENCES Species (SpeciesID)
    );
    Last edited by zmbd; Mar 17 '13, 03:27 PM. Reason: [Z{Please use the <CODE/> formatting button to format your posted code and SQL}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    The construct you are using is incorrect by calling the constraint a second time using the same name.

    This is the reference for SQL:
    > CONSTRAINT Clause (Microsoft Access SQL)(OFFICE 2007)
    There is an example there for multiple field constraint.
    Last edited by zmbd; Mar 17 '13, 03:38 PM.

    Comment

    Working...