My problem is fairly simple. I was been given around 95% of a fairly large, working data set. And I wrote out a parser, set my data out into CSVs, wrote my bulk loads, and have everything set up save the foreign keys.
Now, part of the lost 5% is from one table, (say Items
) that used to contain information that another table, (say Users
) does still have. And since referential integrity is broken between the tables, the foreign keys constraint can't be added, throwing an error 1452
, as the latter table references a record missing in the former.
Now, I don't mind losing this 5% and want to have the 95%. Is there a simple way to just throw out the broken records on adding the foreign key? Or can I do this through some SQL query? Or do I have to go back and re-parse everything to throw out the bad records? I feel like the first or second should be an option. But I just can't find it, as I'm no DB admin... Am I missing something stupidly simple?