Usage
In your app manifest.json, you can define new tables adding aapp_tables property like this:
App tables are removed from the database when the apps are deleted.
Specific columns
Every app table should have the following columns:id and external_id columns are used to identify the records.
The external_id is the ID of the record in your external system, and the id is a SHA1 hash of the external_id used by Rimdian.
The created_at column is used to track the creation of the records in your external system.
The fields_timestamp column is used to track the changes in the record fields.
The db_created_at and db_updated_at columns are used to track the creation and update of the records in the database.
User activity
In order to join the table records to the users activity, theuser_id & merged_from_user_id columns should be added to the table.
When user profiles are merged, the user_id column is updated with the new user ID, and the merged_from_user_id column is updated with the old user ID.
Shard key
Theshard_key is used to distribute the records across the database shards.
The records are grouped by the shard_key and stored in the same shard.
It should contain at least one column.
If you define a user_id column, it’s recommended to use it as the shard_key. This way the records are stored in the same shard as the user activity.
I.e:
Unique key
Theunique_key is used to ensure that the records are unique in the table.
It should contain at least the columns used in the shard_key.
I.e:
Sort key
Thesort_key is used to store the records in the database in a specific order.
It should contain at least one column.
If the data is time-based, it’s recommended to use the created_at column as the sort_key. This way the records are stored in the database in the same order as they were created.
I.e:
Joins
By declaring relationships between the app tables and other tables, the Cube.js semantic layer can join the app tables with other tables.one_to_one, one_to_many or many_to_one. Read more about the Joins directions.