pragma foreign_keys = 0; begin; attach database 'baseball-raw.db' as 'raw'; create temp table if not exists "halloffamereqs" ( "yearID" numeric, "votedBy" text, "ballots" numeric, "needed" numeric, "needed_note" text ); insert into halloffamereqs select distinct yearid, votedby, ballots, needed, "needed_note" from "raw".halloffame; create table if not exists main."halloffamereqs" ( "year" numeric, "votedBy" text, "ballots" numeric, "needed" numeric, "needed_note" text, primary key("year","votedBy"), foreign key("year") references "seasons"("year") ); insert into main.halloffamereqs select distinct * from temp.halloffamereqs; commit;