问题
Say I have a table TB1, for the conditions defined, the list below is unique. The products and emails is Many-to-Many relationship.
I am going to do a survey for the products consumers purchased.
Product Email
TV a@server.com
Fridge a@server.com
Fridge b@server.com
TV c@server.com
Cooler c@server.com
The requirements are:
Each product couldn't be assigned to 2 surveys. Each survey could have multiple products. All customers who have purchased this product should be in the same survey.
Each customer couldn't be assigned to 2 surveys. Each survey could have multiple emails assigned. Each survey is sent to one person, asking how do you like the products listed.
This list is big. The problem is the email server could only handle, say 3000 emails at once. In the cases when there are 7000 unique emails(each email is asking question about all the products the customer bought) to be sent, three SurveyIDs needs to be created. It doesn't mean each has 3000 emails, but it has to meet requirement 1 and 2.
Note: each customer could buy at most 10 products.
Question: How to find out the cohorts of the (product,email) pairs that are independent from other cohorts so that all three requirements could be achieved using ORACLE functions?
In the above scenario, all the records are in one cohort. Either they would go together or not going anywhere.
This is only my thought of resolving the puzzle. If there is any other better idea please let me know.
Thanks a lot!
来源:https://stackoverflow.com/questions/25777460/oracle-sql-split-two-inter-related-lists-into-independent-cohorts