Scenario: bundles of items (m:m).
List the duplicate bundles

Consider an application which maintains items and allows users to create bundles of these items. Each item has various attributes (cost, no. in stock, etc). Each bundle has various attributes (customer, order date, etc). Each bundle may contain one or many items. Each item may be in one or many bundles.

The relational implementation has an items table and a bundles table. The m:m relatioship is implemented as the classical intersections table with columns bundle_id and item_id.

The bundle composition for a given bundle_id is the set of item_id's it contains.

Do many bundles have the same composition? (Exactly the same item_id's but in any order.)

Generate a list of bundle compositions for each distinct composition that is contained in two or more bundles. For each, list the bundle_id's that contain it.