There's a set of values stored in a ms sql db table. These values indicate,
a. serial number of the item
b. capacity of the item
c. availability of the item
I need to design a search function that has following capabilities and to find out an item or combined items to match/nearer a given capacity,
e.g. given capacity is 8. Available items are of capacity 10, 6, 4, 2. There are few items with above capacity. In the best case, result should return items with capacity 10 before deciding to approach the combining algo-part. In the event no single item is found to satisfy the given capacity, algo must proceed to combine, yet only if adequate number of items are available to combine...
- Rule of search : all combined items must be adjacent by serial number)
- Combined capacity should be an exact or a near match (greater than) given capacity
- Items must be available (Boolean value check)
How should I approach for this? The tough part could be finding total capacity of combined items while they are adjacent to each other. Currently I am thinking of each pulling data into C# and do the search or do entire search within SQL via a stored procedure. All ears to hear and try out any suggestions that could get better performance and satisfies the main criteria.