I want to verify the correctness of the data inside a junction table data.
I'm showing a minimal example here:
Products:
| Id | EnglishName |
|---|---|
| 1 | Drill 4 |
| 2 | Light Switch 48 |
Suppliers:
| Id | EnglishName |
|---|---|
| 1 | Bosch |
| 2 | Ingco |
| 3 | Yato |
Excel2:
| Product | Supplier |
|---|---|
| Drill 4 | Bosch |
| Light Switch 48 | Ingco |
| Cable 12 | Bosch |
| Hammer 14 | Yato |
ProductsSuppliers:
| ProductId | SupplierId |
|---|---|
| 1 | 1 |
| 1 | 3 |
| 2 | 1 |
Excel2JoinProductsJoinSuppliers :
| Product | Supplier | ProductId | SupplierId |
|---|---|---|---|
| Drill 4 | Bosch | 1 | 1 |
| Drill 4 | Yato | 1 | 3 |
| Light Switch 48 | Bosch | 2 | 1 |
A C# code was used to insert data into Products , Suppliers , and ProductsSuppliers .
The data for Excel2 was imported into Sql Server manually using the "Import Data" wizard.
As the name suggest, Excel2JoinProductsJoinSuppliers is the result of join operation.
ProductsSuppliers is then junction table that I'm concerned about, the data inside it is correct in this example because each productId is mapped to the correct value of SupplierId and vice versa, but the actual table contains much more data, let alone the fact that there are other junction tables that should be verified.
Is there a set-based approach that can automate the process of verify the data for junction table ?