I have a single table formed from an import, which contains a variety of data on files. I want to insert that data into my normalized table structure, but I'm unsure on the best way to do that. The import table contains the following:
The target tables are set up as follows:
Id int primary key identity,
I have to pull the values from the import table, and insert them into the Media and Hashes table if they don't already exist there. If they do exist in the target tables then I need to simply update them. Updates are only needed if a category changes or another hash is added. The MD5 is available for all records, but they other hashes may or may not be present.
What's the best way to tackle this? My first thought was to check if the MD5 hash exists and insert if it does not. Is that the best/only option?