Adjust for 2nf

This commit is contained in:
Nick Griffey 2024-01-26 13:32:45 -06:00
parent 0d00bddead
commit 7b04bfb776
2 changed files with 16 additions and 1 deletions

15
sql/2nf/allstargames.sql Normal file
View File

@ -0,0 +1,15 @@
begin;
create table if not exists allstargames (
"gameID" text,
"yearID" numeric,
"gameNum" numeric,
primary key("gameID")
);
insert into allstargames
select distinct gameid, yearid, gamenum
from allstarfull;
alter table allstarfull drop column "yearID";
alter table allstarfull drop column "gameNum";
commit;

View File

@ -8,7 +8,7 @@ CREATE TABLE "pk_allstarfull" (
"lgID" NUMERIC,
"GP" NUMERIC,
"startingPos" NUMERIC,
primary key("playerID","yearID","gameNum","startingPos"),
primary key("playerID","gameID","startingPos"),
foreign key("playerID") references "people"("playerID")
);