Multiple user types Database configure and Nesting of data types

I’m trying to build a website which has 3 types of users. So when i sign up users i want to give them one of the 3 roles. The problem is that the fields i want to store for the user varies with the type of user.

So for example i have 3 roles: A,B and C and they have their own different attributes:

My “User” data type has an attribute called Role whose data type is “User type”

In “user type” custom data type i want to store 3 values A,B and C.

How do i link (A,B,C) to “user type” and “user type” to “user” data type? How do i sign them up? Would appreciate any other ways to execute this.

Alternatively consider the following structure:

  • Option set named “User type” with options A, B, or C
  • Create the above option set field under User and call it also User type
    -Since you do not require that much metadata about each user, you could keep this simple and just create all the needed metatada fields under User
  • Conditionally build a sign up flow where the respective metadata will be filled out depending on whether they are A, B. or C
  • If you still prefer to keep the metadata of each user separate from the User data-type … then just create a new thing and call it “metadata” and add all the necessary fields. Add a metadata field in the user data-type. And build into the sign-up flow the creation of a new metadata entry and add it to the new user’s metadata field.

Hope the above makes sense. :+1:

1 Like

Thanks for such a quick reply. Actually i plan to add a lot of metadata to each user so i want to keep it separate in the database. I followed your last advice. But i cant get it to work.
I made a thing ‘metadata’ and added it to user.

Then i added my fields to metadata

But now when i sign up i am unable to input these fields through metadata.

You cannot add because it does not exist. You have not created it first.

In the flow, proceed to sign the user up, then create the metadata (make sure to relate it to the user by creating a field called user of type user), then modify a user and add the recently created metadata of step #2

1 Like

I think i got it. I will write an explanation down below.
First of all, to link both the data types, i added attribute metadata of data type ‘metadata’ in user data type. In data type ‘metadata’ i added attribute user of ‘user’ data type. This makes a link between both.
During signup, we can directly change fields which are attributes of ‘user’ data type. Attributes of ‘metadata’ data type were not direct attributes of ‘user’ data type and hence i could not change them directly through signup workflow.
To change such ‘composite data types’ i.e. those which are nested/linked, i used data-make changes to a thing in the workflow. Then in thing to change i chose current user’s metadata. Since i want to change a field inside metadata, i clicked on change another field and chose the field i wanted to modify. In that i took data from the input value.
Thank you @cmarchan for your help. I apologise for the delayed response from my side. Hope this is helpful for future bubblers.

2 Likes