Can a table have two foreign keys?

前端 未结 4 1816
一整个雨季
一整个雨季 2021-02-02 10:02

I have the following tables (Primary key in bold. Foreign key in Italic)

Customer table

  • ID---Name---Balance---
4条回答
  •  旧时难觅i
    2021-02-02 11:05

    CREATE TABLE User (
    user_id INT NOT NULL AUTO_INCREMENT,
    userName VARCHAR(100) NOT NULL,
    password VARCHAR(255) NOT NULL,
    email VARCHAR(255) NOT NULL,
    userImage  LONGBLOB NOT NULL, 
    Favorite VARCHAR(255) NOT NULL,
    PRIMARY KEY (user_id)
    );
    

    and

    CREATE TABLE Event (
        EventID INT NOT NULL AUTO_INCREMENT, 
        PRIMARY KEY (EventID),
        EventName VARCHAR(100) NOT NULL,
        EventLocation VARCHAR(100) NOT NULL,
        EventPriceRange VARCHAR(100) NOT NULL,
        EventDate Date NOT NULL,
        EventTime Time NOT NULL,
        EventDescription VARCHAR(255) NOT NULL,
        EventCategory VARCHAR(255) NOT NULL,
        EventImage  LONGBLOB NOT NULL,     
        index(EventID),
        FOREIGN KEY (EventID) REFERENCES User(user_id)
    );
    

提交回复
热议问题