generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Data Model approaches
Vikhyat Bhatnagar edited this page Mar 25, 2023
·
3 revisions
{
"id": string,
"flagName": string,
"createdAt": number,
"createdBy": string,
"deactivatedAt": number,
"description": string
}
{
'id': string,
'username': string,
'first_name': string,
'last_name': string,
'email': string,
'phone': number,
'yoe': number,
'company': string,
'designation': string,
'img': string,
'github_id': string,
'linkedin_id': string,
'twitter_id': string,
'instagram_id': string,
'website': string,
'github_display_name': string,
'isMember': boolean,
'userType': string,
'tokens': {},
'badges': []
}
One drawback of having a separate table for user feature mapping, can be if we want to release feature X for 100 users, we need to make 100 entries in the FeatureFlagUserMapping table.
For fetching the flag of User X, need to scan all the entries with index on UserId
{
'flagId': string,
'userId': string,
'enabled': boolean
'enabledAt': timestamp
}
{
"id": string,
"flagName": string,
"createdAt": number,
"createdBy": string,
"deletedAt": number
}
{
'id': string,
'username': string,
'first_name': string,
'last_name': string,
'email': string,
'phone': number,
'yoe': number,
'company': string,
'designation': string,
'img': string,
'github_id': string,
'linkedin_id': string,
'twitter_id': string,
'instagram_id': string,
'website': string,
'github_display_name': string,
'isMember': boolean,
'userType': string,
'tokens': {},
'badges': [],
**'flags': []**
}
One drawback of this approach is that if we have many feature flags for a User, the list of flags would become very large. We can fetch feature flags for Users, but the other way is not possible i.e: Fetching Users from the Feature flag.
{
"id": string,
"flagName": string,
"createdAt": number,
"createdBy": string,
"deletedAt": number,
"Users": []
}
Need to think more about faster querying for a user. Given a user check if the flag is enabled.
{
'id': string,
'username': string,
'first_name': string,
'last_name': string,
'email': string,
'phone': number,
'yoe': number,
'company': string,
'designation': string,
'img': string,
'github_id': string,
'linkedin_id': string,
'twitter_id': string,
'instagram_id': string,
'website': string,
'github_display_name': string,
'isMember': boolean,
'userType': string,
'tokens': {},
'badges': [],
'flags': []
}
We have to update the data in 2 models, append the flag in flags of User model and append the User in Users of flag model.