Remove foreign key constraints on teamid
This commit is contained in:
parent
3bd573b00d
commit
f6f17cc47c
|
@ -9,8 +9,7 @@ CREATE TABLE "pk_allstarfull" (
|
||||||
"GP" NUMERIC,
|
"GP" NUMERIC,
|
||||||
"startingPos" NUMERIC,
|
"startingPos" NUMERIC,
|
||||||
primary key("playerID","yearID","gameNum","startingPos"),
|
primary key("playerID","yearID","gameNum","startingPos"),
|
||||||
foreign key("playerID") references "people"("playerID"),
|
foreign key("playerID") references "people"("playerID")
|
||||||
foreign key("teamID") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "pk_allstarfull" SELECT DISTINCT * FROM "allstarfull";
|
INSERT INTO "pk_allstarfull" SELECT DISTINCT * FROM "allstarfull";
|
||||||
|
|
|
@ -22,8 +22,7 @@ CREATE TABLE IF NOT EXISTS "pk_appearances" (
|
||||||
"G_ph" NUMERIC,
|
"G_ph" NUMERIC,
|
||||||
"G_pr" NUMERIC,
|
"G_pr" NUMERIC,
|
||||||
PRIMARY KEY("yearID","teamID","playerID"),
|
PRIMARY KEY("yearID","teamID","playerID"),
|
||||||
foreign key("playerID") references "people"("playerID"),
|
foreign key("playerID") references "people"("playerID")
|
||||||
foreign key("teamID") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "pk_appearances" SELECT DISTINCT * FROM "appearances";
|
INSERT INTO "pk_appearances" SELECT DISTINCT * FROM "appearances";
|
||||||
|
|
|
@ -23,8 +23,7 @@ CREATE TABLE IF NOT EXISTS "pk_batting" (
|
||||||
"SF" NUMERIC,
|
"SF" NUMERIC,
|
||||||
"GIDP" NUMERIC,
|
"GIDP" NUMERIC,
|
||||||
PRIMARY KEY("playerID","yearID","stint","teamID"),
|
PRIMARY KEY("playerID","yearID","stint","teamID"),
|
||||||
foreign key("playerID") references "people"("playerID"),
|
foreign key("playerID") references "people"("playerID")
|
||||||
foreign key("teamID") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "pk_batting" SELECT DISTINCT * FROM "batting";
|
INSERT INTO "pk_batting" SELECT DISTINCT * FROM "batting";
|
||||||
|
|
|
@ -23,8 +23,7 @@ CREATE TABLE IF NOT EXISTS "pk_battingpost" (
|
||||||
"SF" NUMERIC,
|
"SF" NUMERIC,
|
||||||
"GIDP" NUMERIC,
|
"GIDP" NUMERIC,
|
||||||
PRIMARY KEY("yearID","playerID","round"),
|
PRIMARY KEY("yearID","playerID","round"),
|
||||||
foreign key("playerID") references "people"("playerID"),
|
foreign key("playerID") references "people"("playerID")
|
||||||
foreign key("teamID") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "pk_battingpost" SELECT DISTINCT * FROM "battingpost";
|
INSERT INTO "pk_battingpost" SELECT DISTINCT * FROM "battingpost";
|
||||||
|
|
|
@ -19,8 +19,7 @@ CREATE TABLE IF NOT EXISTS "pk_fielding" (
|
||||||
"CS" NUMERIC,
|
"CS" NUMERIC,
|
||||||
"ZR" NUMERIC,
|
"ZR" NUMERIC,
|
||||||
PRIMARY KEY("playerID","yearID","stint","teamID","POS"),
|
PRIMARY KEY("playerID","yearID","stint","teamID","POS"),
|
||||||
foreign key("playerID") references "people"("playerID"),
|
foreign key("playerID") references "people"("playerID")
|
||||||
foreign key("teamID") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "pk_fielding" SELECT DISTINCT * FROM "fielding";
|
INSERT INTO "pk_fielding" SELECT DISTINCT * FROM "fielding";
|
||||||
|
|
|
@ -19,8 +19,7 @@ CREATE TABLE IF NOT EXISTS "pk_fieldingofsplit" (
|
||||||
"CS" NUMERIC,
|
"CS" NUMERIC,
|
||||||
"ZR" NUMERIC,
|
"ZR" NUMERIC,
|
||||||
PRIMARY KEY("playerID","yearID","stint","teamID","POS"),
|
PRIMARY KEY("playerID","yearID","stint","teamID","POS"),
|
||||||
foreign key("playerID") references "people"("playerID"),
|
foreign key("playerID") references "people"("playerID")
|
||||||
foreign key("teamID") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "pk_fieldingofsplit" SELECT DISTINCT * FROM "fieldingofsplit";
|
INSERT INTO "pk_fieldingofsplit" SELECT DISTINCT * FROM "fieldingofsplit";
|
||||||
|
|
|
@ -18,8 +18,7 @@ CREATE TABLE IF NOT EXISTS "pk_fieldingpost" (
|
||||||
"SB" NUMERIC,
|
"SB" NUMERIC,
|
||||||
"CS" NUMERIC,
|
"CS" NUMERIC,
|
||||||
PRIMARY KEY("playerID","yearID","round","POS"),
|
PRIMARY KEY("playerID","yearID","round","POS"),
|
||||||
foreign key("playerID") references "people"("playerID"),
|
foreign key("playerID") references "people"("playerID")
|
||||||
foreign key("teamID") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "pk_fieldingpost" SELECT DISTINCT * FROM "fieldingpost";
|
INSERT INTO "pk_fieldingpost" SELECT DISTINCT * FROM "fieldingpost";
|
||||||
|
|
|
@ -10,7 +10,6 @@ CREATE TABLE IF NOT EXISTS "pk_homegames" (
|
||||||
"openings" NUMERIC,
|
"openings" NUMERIC,
|
||||||
"attendance" NUMERIC,
|
"attendance" NUMERIC,
|
||||||
PRIMARY KEY("year.key","team.key","park.key"),
|
PRIMARY KEY("year.key","team.key","park.key"),
|
||||||
foreign key("team.key") references "teams"("teamID"),
|
|
||||||
foreign key("park.key") references "parks"("park.key")
|
foreign key("park.key") references "parks"("park.key")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,7 @@ CREATE TABLE IF NOT EXISTS "pk_managers" (
|
||||||
"rank" NUMERIC,
|
"rank" NUMERIC,
|
||||||
"plyrMgr" TEXT,
|
"plyrMgr" TEXT,
|
||||||
PRIMARY KEY("playerID","yearID","teamID","inseason"),
|
PRIMARY KEY("playerID","yearID","teamID","inseason"),
|
||||||
foreign key("playerID") references "people"("playerID"),
|
foreign key("playerID") references "people"("playerID")
|
||||||
foreign key("teamID") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
INSERT INTO "pk_managers" SELECT DISTINCT * FROM "managers";
|
INSERT INTO "pk_managers" SELECT DISTINCT * FROM "managers";
|
||||||
DROP TABLE "managers";
|
DROP TABLE "managers";
|
||||||
|
|
|
@ -11,8 +11,7 @@ CREATE TABLE IF NOT EXISTS "pk_managershalf" (
|
||||||
"L" NUMERIC,
|
"L" NUMERIC,
|
||||||
"rank" NUMERIC,
|
"rank" NUMERIC,
|
||||||
PRIMARY KEY("playerID","yearID","teamID","inseason","half"),
|
PRIMARY KEY("playerID","yearID","teamID","inseason","half"),
|
||||||
foreign key("playerID") references "people"("playerID"),
|
foreign key("playerID") references "people"("playerID")
|
||||||
foreign key("teamID") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "pk_managershalf" SELECT DISTINCT * FROM "managershalf";
|
INSERT INTO "pk_managershalf" SELECT DISTINCT * FROM "managershalf";
|
||||||
|
|
|
@ -31,8 +31,7 @@ CREATE TABLE IF NOT EXISTS "pk_pitching" (
|
||||||
"SF" NUMERIC,
|
"SF" NUMERIC,
|
||||||
"GIDP" NUMERIC,
|
"GIDP" NUMERIC,
|
||||||
PRIMARY KEY("playerID","yearID","stint","teamID"),
|
PRIMARY KEY("playerID","yearID","stint","teamID"),
|
||||||
foreign key("playerID") references "people"("playerID"),
|
foreign key("playerID") references "people"("playerID")
|
||||||
foreign key("teamID") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "pk_pitching" SELECT DISTINCT * FROM "pitching";
|
INSERT INTO "pk_pitching" SELECT DISTINCT * FROM "pitching";
|
||||||
|
|
|
@ -31,8 +31,7 @@ CREATE TABLE IF NOT EXISTS "pk_pitchingpost" (
|
||||||
"SF" NUMERIC,
|
"SF" NUMERIC,
|
||||||
"GIDP" NUMERIC,
|
"GIDP" NUMERIC,
|
||||||
PRIMARY KEY("playerID","yearID","round"),
|
PRIMARY KEY("playerID","yearID","round"),
|
||||||
foreign key("playerID") references "people"("playerID"),
|
foreign key("playerID") references "people"("playerID")
|
||||||
foreign key("teamID") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "pk_pitchingpost" SELECT DISTINCT * FROM "pitchingpost";
|
INSERT INTO "pk_pitchingpost" SELECT DISTINCT * FROM "pitchingpost";
|
||||||
|
|
|
@ -6,8 +6,7 @@ CREATE TABLE IF NOT EXISTS "pk_salaries" (
|
||||||
"playerID" TEXT,
|
"playerID" TEXT,
|
||||||
"salary" NUMERIC,
|
"salary" NUMERIC,
|
||||||
PRIMARY KEY("yearID","playerID","teamID"),
|
PRIMARY KEY("yearID","playerID","teamID"),
|
||||||
foreign key("playerID") references "people"("playerID"),
|
foreign key("playerID") references "people"("playerID")
|
||||||
foreign key("teamID") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "pk_salaries" SELECT DISTINCT * FROM "salaries";
|
INSERT INTO "pk_salaries" SELECT DISTINCT * FROM "salaries";
|
||||||
|
|
|
@ -9,9 +9,7 @@ CREATE TABLE IF NOT EXISTS "pk_seriespost" (
|
||||||
"wins" NUMERIC,
|
"wins" NUMERIC,
|
||||||
"losses" NUMERIC,
|
"losses" NUMERIC,
|
||||||
"ties" NUMERIC,
|
"ties" NUMERIC,
|
||||||
PRIMARY KEY("yearID","round"),
|
PRIMARY KEY("yearID","round")
|
||||||
foreign key("teamIDwinner") references "teams"("teamID"),
|
|
||||||
foreign key("teamIDloser") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "pk_seriespost" SELECT DISTINCT * FROM "seriespost";
|
INSERT INTO "pk_seriespost" SELECT DISTINCT * FROM "seriespost";
|
||||||
|
|
|
@ -10,8 +10,7 @@ CREATE TABLE IF NOT EXISTS "pk_teamshalf" (
|
||||||
"G" NUMERIC,
|
"G" NUMERIC,
|
||||||
"W" NUMERIC,
|
"W" NUMERIC,
|
||||||
"L" NUMERIC,
|
"L" NUMERIC,
|
||||||
PRIMARY KEY("Half","yearID","teamID"),
|
PRIMARY KEY("Half","yearID","teamID")
|
||||||
foreign key("teamID") references "teams"("teamID")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO "pk_teamshalf" SELECT DISTINCT * FROM "teamshalf";
|
INSERT INTO "pk_teamshalf" SELECT DISTINCT * FROM "teamshalf";
|
||||||
|
|
Loading…
Reference in New Issue