How do I make the 1:n relantions using SQL in MySQL Workbench?

35 views Asked by At

image1 image2

I'm brand new to SQL and mySQL workbench. I'm trying to get the one to many relantionship from team_id to home_id and the one to many relantionship from team_name to visitor_id. I cannot get the relantionships when reverse engineering the database. How do I create these relantionships.

THis is how I created the tables. I would think the REFERENCES would created the relantionship.

CREATE TABLE TEAM (
    team_id INT PRIMARY KEY,
    team_name VARCHAR(255),
    team_mascot VARCHAR(255)
);


CREATE TABLE GAME (
    home_id INT,
    visitor_id INT,
    FOREIGN KEY (home_id) REFERENCES TEAM(team_id),
    FOREIGN KEY (visitor_id) REFERENCES TEAM(team_id)
);

Thank you for the Help

0

There are 0 answers