Store horizontal expanding data in MySQL
Hello everyone!
I need to implement something very similar to mailchimp segments. They look like: Mailchimp segments
So, I have a Contact model, which has many attributes and relationships. I can filter this entity by various conditions, like, choose all contacts without email or which have some activities or whatever. Many kinds of filters, and all of them are different and not predictable.
Now I added two models: Segment and SegmentFilter. So let's say I want to get all contacts without email and with phone and contacts which made a call to me after specific date. So this segment has 3 filters:
- Email - is - blank
- Phone - is not - blank
- Activity - Call - After - Specific date
At first I made segment filters table with three columns like: condition, type, value (email, =, blank). Now I need another filter (the call activity) which consists of four parts. If you take a look at the mailchimp segments there are some complex filters like here: Segments
you can see "Location - is within - 25 miles of - city"
So how should I store all that data? I dont feel like making columns "part1 part2 part3 part4 part5" is something I should do :)
Please or to participate in this conversation.