DROP TABLE TEAMPLAYER ;
DROP TABLE PLAYER ;
DROP TABLE TEAM ;
DROP TABLE LEAGUE ;

CREATE TABLE PLAYER
(
    PLAYER_ID VARCHAR(255) PRIMARY KEY,
    NAME      VARCHAR(255),
    POSITION  VARCHAR(255),
    SALARY DOUBLE PRECISION NOT NULL
) ENGINE=INNODB;

CREATE TABLE LEAGUE
(
    LEAGUE_ID VARCHAR(255) PRIMARY KEY,
    NAME      VARCHAR(255),
    SPORT     VARCHAR(255)
) ENGINE=INNODB;

CREATE TABLE TEAM
(
    TEAM_ID   VARCHAR(255) PRIMARY KEY,
    CITY      VARCHAR(255),
    NAME      VARCHAR(255),
    LEAGUE_ID VARCHAR(255)
) ENGINE=INNODB;

CREATE TABLE TEAMPLAYER
(
    PLAYER_ID VARCHAR(255),
    TEAM_ID   VARCHAR(255),
    CONSTRAINT PK_TEAMPLAYER PRIMARY KEY (PLAYER_ID, TEAM_ID)
) ENGINE=INNODB;

commit;

quit;
