0

Short Description

I have a database of special offers that bundle several items together. I want to be able to search for a list of specific items and get a combination of bundles that includes all those items with the fewest unwanted extras.

Example

My database has bundles like these:

Bundle 1: Item A X2, Item B X1, Item D X4
Bundle 2: Item A X5, Item C X1, Item E X3
Bundle 3: Item B X2, Item C X3, Item D X3
Bundle 4: Item C X10, Item D X1, Item F X4

I want 10 of Item A, 4 of Item C, and 1 of Item E. I want to search for a combination of bundles that yields the items I want with the fewest extra items. The items I want can vary and should be easily editable in the search.

Qanthelas
  • 101
  • 1
    Can you give an example of the schema with CREATE statements? – James Anderson Oct 07 '14 at 15:00
  • Which DBMS are you using? Postgres? Oracle? –  Oct 07 '14 at 15:14
  • The honest truth is that I am looking at the idea in general, rather than for a specific architecture or DBMS. Currently I'm just using .csv files to build a dictionary of the data an manipulate that, looking at moving to sqlite. The point of the question, though, is more about the idea, the algorithm, the thought process (rather than a specific piece of code for a specific build.) – Qanthelas Oct 07 '14 at 16:18

1 Answers1

0

I don't think anyone has come up with a complete answer for your question. This sounds like a complex math question which does not belong on the "Database Administrators" site.

With that said, Joe Celko has an article that might help you. Bin Packing Problems: The SQL

DavidN
  • 591
  • 4
  • 9