I need to retrieve data from MsAccess/SQL Server (two separate projects in which I face similar problem) using c#.net (3.5), preferably fast and with code that is understandable/maintainable/simple.
I have the following tables with columns. For each, the columns in bold are the key (indexed as well).
- SKU info (~1000 000 records) : PNO, description,leadtime, price, etcetera
- Usage information (~200 000 records) : OrderNO, PNO, description,date, quantity, unit of measure, etcetera
- InterchangeAbility (~100 000 records) : PNO,description (PNO1, description1, etcetera)
The last table indicates that (PNO1, description1) is the successor SKU of (PNO,description). Note that (PNO1, description1) may in turn have a successor as well.
I need to retrieve and store in memory:
- All usage
- SKU information for any part with for which there is usage (about 20000 parts)
- All relevant interchangeability records, which say something about parts for which there was usage or parts that are the successor variants of parts for which there was usage etcetera.
- SKU information for any relevant preferred parts (about 2000 parts)
Does anybody have a good maintainable solution for this problem?
The most promising approach seems to be to determine on the database side with SKUs are relevant. Problem is, that relevancy is inductively defined. How to do this?
Attempted to figure out how the problem of finding relevant interchangeability might be solved using a CTE. Quickly got out of hand. You might be able to get something from it still. It shouldn’t be too inefficient, despite it’s size, assuming my thinking isn’t completely wrong.
Each of the queries inside the CTE is basically a temporary view you can access from the CTE. The Preferred, Roots and HasUsage bits don’t depend on any of the other CTE tables, so they could actually even be views if you needed.