Storing user-defined query logic in a database for filtering entity data
Apparatuses, methods, and systems for filtering entities within a database based on rules of a user-defined segment definition. One method includes creating data tables for storing user-defined segment definitions in the database, the data tables including the user-defined segment definitions and criteria, receiving new user-defined segment definitions, transforming the new user-defined segment definitions, storing the transformed new user-defined segment definitions in the database, composing a user-defined query based on the transformed new user-defined segment definitions as stored in the database, wherein the user-defined query contains logic that interprets the filter definition tuples as native operations provided by the database, and running the composed user-defined query against the data tables to determine which of the entities qualify for membership in new segments based on each of the new user-defined segment definitions as determined by the logic contained in the composed user-defined query.
1 . A method of filtering entities within a database based on rules of a user-defined segment definition applied to various data points associated with each entity stored in the database, comprising: creating data tables for storing user-defined segment definitions in the database, the data tables including the user-defined segment definitions and criteria, wherein the criteria include rules that are evaluated against entity data of the database to determine whether an entity should or should not qualify for a segment based on entity data associated with the entity, wherein the entity data includes data of sub-users of sub-user computing devices and includes at least an email history a of the sub-users;
receiving, by a segmentation system, new user-defined segment definitions;
transforming, by the segmentation system, the new user-defined segment definitions, wherein transforming includes representing the new user-defined segment definitions as sets of filter definition tuples, wherein the sets of filter definition tuples are based on the user-defined segment definitions and the criteria in the created data tables, wherein the sets of filter definition tuples include a field type that allows properties of the sets of filter definition tuples to be cast to different types at query time, thereby allowing an operator of the server to not enforce a rigid typed schema on customer-provided data, wherein the set of filter definition tuples include a set of transformed representations of the criteria that map directly to operations that the database knows how to perform, wherein the set of filter definition tuples are implemented as calls to function implemented by the database;
storing, by the segmentation system, the transformed new user-defined segment definitions in the database, making an SQL query generic, thereby allowing any number of segments to be evaluated simultaneously in one SQL query, and protecting from SQL injection attacks since the generic SQL query in is not pieced together from user-provided strings;
composing a user-defined query based on the transformed new user-defined segment definitions as stored in the database, wherein the user-defined query contains logic that interprets the sets of filter definition tuples as native operations provided by the database, wherein the native operations include operations built into the database as opposed to being separately defined, thereby enabling calls to functions to be built into SQL implementations provided by the database, wherein the logic that interprets the sets of filter definition tuples operates as a standard generic SQL without being prone to SQL injection attacks;
and running the composed user-defined query against the data tables to determine which of the entities qualify for membership in new segments based on each of the new user-defined segment definitions as determined by the logic contained in the composed user-defined query.
2 . The method of claim 1 , wherein running the composed user-defined query against the data tables provides a filtered set of entities per the new user-defined segment definitions.
3 . The method of claim 1 , further comprising electronically performing an action directed to users identified by membership in the new segments.
4 . The method of claim 1 , wherein each of the entities comprises a profile, wherein each profile comprises information of sub-users, wherein the sub-users are customer of the user.
5 . The method of claim 1 , wherein each segment includes a list of entities, wherein membership of each of the entities is determined by the composed user-defined query based on the new user-defined segment definitions.
6 . The method of claim 1 , further comprising creating and storing a trait and event table in the database as a part of the entity data of the data tables, wherein the entity data further includes event data and trait criteria, wherein the event data is filtered first on its properties by iterating over each property filter tuple, evaluating the event data using filtering functions, and combining results with an AND, wherein event data that does not satisfy the filtering functions is removed from consideration, and wherein remaining event data is then grouped by an entity they are related to, and wherein trait criteria is loaded, and properties associated with the trait criteria are filtered as the event data is filtered except there is only one trait row for each profile and trait type, thereby not requiring aggregation, wherein when the one trait row passes combined property filters the profile qualifies for the trait criteria.
7 . The method of claim 6 , wherein the entity data includes an email address of a sub-user.
8 . The method of claim 1 , wherein the entity data includes time-series data.
9 . The method of claim 8 , wherein the time-series data includes at least one of a purchase history or an email history of a the sub-user.
10 . The method of claim 1 , further comprising updating overall segments as entity data changes, comprising: sensing changes in the entity data;
and automatically re-running the composed user-defined query against the data tables to determine which of the entities qualify for membership in new segments based on each of the new user-defined segment definitions as determined by the logic contained in the composed user-defined query.
11 . The method of claim 1 , further comprising: electronically sending messages to sub-users identified by membership in the new segments.
12 . The method of claim 1 , wherein the user-defined segment definitions include lists of references to the criteria, wherein the user-defined segment definitions include the criteria and rules for combining the results of the criteria with Boolean operations AND and OR.
13 . A system for filtering entities based on rules of a user-defined segment definition, comprising: a server;
a database, wherein entities are stored in the database;
a user server electronically connected to the server;
sub-user computing devices electronically connected to the server and the user server, wherein the entity data includes data of sub-users of the sub-user computing devices; the server configured to:
create data tables for storing user-defined segment definitions in the database, the data tables including the user-defined segment definitions and criteria, wherein the criteria include rules that are evaluated against entity data of the database to determine whether an entity should or should not qualify for a segment based on entity data associated with the entity, wherein the entity data includes data of sub-users of sub-user computing devices and includes at least an email history a of the sub-users;
receive new user-defined segment definitions from a user of the user server; transform the new user-defined segment definitions, wherein transforming includes representing the new user-defined segment definitions as sets of filter definition tuples, wherein the sets of filter definition tuples are based on the user-defined segment definitions and the criteria in the created data tables wherein the sets of filter definition tuples include a field type that allows properties of the sets of filter definition tuples to be cast to different types at query time, thereby allowing an operator of the server to not enforce a rigid typed schema on customer-provided data, wherein the set of filter definition tuples include a set of transformed representations of the criteria that map directly to operations that the database knows how to perform, wherein the set of filter definition tuples are implemented as calls to function implemented by the database;
store the transformed new user-defined segment definitions in the database, making an SQL query generic, thereby allowing any number of segments to be evaluated simultaneously in one SQL query, and protecting from SQL injection attacks since the SQL query in not pieced together from user-provided strings;
compose a user-defined query based on the transformed new user-defined segment definitions as stored in the database, wherein the user-defined query contains logic that interprets the sets of filter definition tuples as native operations provided by the database, wherein the native operations include operations built into the database as opposed to being separately defined, thereby enabling calls to functions to be built into SQL implementations provided by the database, wherein the logic that interprets the sets of filter definition tuples operates as a standard generic SQL without being prone to SQL injection attacks;
and run the composed user-defined query against the data tables to determine which of the entities qualify for membership in new segments based on each of the new user-defined segment definitions as determined by the logic contained in the composed user-defined query.
14 . The system of claim 13 , wherein the server is further configured to run the composed user-defined query against the data tables to provide a filtered set of entities per the new user-defined segment definitions.
15 . The system of claim 13 , wherein the server is further configured to electronically perform an action directed to users identified by membership in the new segments.
16 . The system of claim 13 , wherein running the composed user-defined query provides for filtering for multiple segments simultaneously.
17 . The system of claim 13 , wherein the entity data includes time-series data, wherein the time-series data further includes at least one of a purchase history or an email history of a sub-user.
18 . The system of claim 13 , the server updating overall segments as entity data changes, comprises the server being further configured to: sense changes in the entity data;
and automatically re-run the composed user-defined query against the data tables to determine which of the entities qualify for membership in new segments based on each of the new user-defined segment definitions as determined by the logic contained in the composed user-defined query.
19 . The system of claim 13 , wherein the server is further configured to electronically send messages to sub-users identified by membership in the new segments.
20 . The system of claim 13 , wherein the server is further configured to: create and store a trait and event table in the database as a part of the entity data of the data tables, wherein the entity data further includes event data and trait criteria, wherein the event data is filtered first on its properties by iterating over each property filter tuple, evaluating the event data using filtering functions, and combining results with an AND, wherein event data that does not satisfy the filtering functions is removed from consideration, and wherein remaining event data is then grouped by an entity they are related to, and wherein trait criteria is loaded, and properties associated with the trait criteria are filtered as the event data is filtered except there is only one trait row for each profile and trait type, thereby not requiring aggregation, wherein when the one trait row passes combined property filters the profile qualifies for the trait criteria.