Data Preparation Best Practices
Use these practices to prepare source tables before building a Kumo Relational schema.
Table Structure and Entity Design
-
Model one entity type or event type per table:
-
Use a single event-time column per table:
-
Model many-to-many relationships with junction tables:
Data Preparation
-
Modify dtypes at the
pandas.DataFramelevel before building a schema: -
Use consistent naming conventions:
Relationship inference links a column only to a primary key of exactly the same name, so
orders.user_idfindsusers.user_idbut notusers.id. A name shared by more than one table’s primary key is ambiguous and links nothing. -
Ensure that primary keys are unique and non-null:
Plan Semantic Types
Before building the schema, determine how Kumo Relational must interpret important columns:
- Identifiers and relationship keys must use
ID. - Free-form descriptions must use
text. The current model does not readtextfeatures for prediction — see Data Types — so this is about correct typing, not a way to improve predictions. - Labels from a finite set must use
categorical. - Quantities and measurements must use
numerical. - Event times must use
timestamp.
After building the schema, review and correct the inferred semantic types.
Plan Prediction-Ready Relationships
Consider the PQL queries that you want to run when preparing source tables. For example, predicting future transaction activity for each user requires an entity table for users, a timestamped event table for transactions, and a key that relates each transaction to a user.
Common Data Modeling Patterns
Entity-event pattern
Hierarchical entities
Junction table for a many-to-many relationship
Pairs table, for ranking over a fixed candidate set
See Prediction Types for why this pattern scales better than ranking a raw candidate list.
Summary
Following these best practices helps ensure that your Kumo Relational datasets are well-structured, validated, and optimized for performance.
Table design:
- Model one entity type or event type per table.
- Use a single event-time column per table.
- Use unique primary keys with consistent key names.
- Model many-to-many relationships with junction tables.
Data Preparation:
- Set the appropriate pandas dtypes before building the schema.
- Plan meaningful semantic types such as
ID,categorical,text, andnumerical.
Relationship planning:
- Prepare consistent key columns for meaningful relationships between entities.
- Consider PQL query requirements when structuring the data.
These patterns help produce source data that is ready for schema building.