You can import you file in the table of the following structure: Diner, Beverage, Food, Dessert, ID (identity, primary key NOT CLUSTERED - for performance issues).
After this simply add the following columns: Dinner_ID
, Beverage_ID
, Dessert_ID
and fill them according to your separate tables (it's simple to group each of the columns and to add the missing data to lookup tables as Beverages
, Desserts
, Meals
and, after this, to fix the imported table with the IDs for existent and newly added records).
The situation with Food
table is more complex because of ability to combine
the foods, but the same trick can be used: you can also add the data to your lookup table and, among this, store the combinations of foods in the additional temp table (with the unique ID) and separation on the single dishes.
When the parcing will be finished, you will have 3 temp tables:
- table with all your imported data and IDs for all text columns
- table with distinct food lists (with IDs)
- table with IDs of food per food combination
From the above tables you can perform the insertion of the parsed values to either structure as you want.
In this case only 1 insert (bulk) will be done to the DB from the code side. All other data manipulations will be performed in the DB.