# Built in way to define categorical data types

**URL:** <https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376>\
**Category:** Idea\
**Created:** [April 25, 2019, 8:52pm UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376 "2019-04-25T20:52:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![zelus\_pudding](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/zelus_pudding/32/68250_2.png) [@zelus\_pudding](https://forum.bubble.io/u/zelus_pudding)\
**Post date:** [April 25, 2019, 8:52pm UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/1 "2019-04-25T20:52:20Z")

</div>

Let’s talk about categorical data folks. As of today Bubble can codify a data value as only having two states (via the `Yes / No` field type) or an infinite number of states (via any other field type). There is no in between.

For example if I want to categorize a user who fits into [one of 5 states like](https://developers.google.com/my-business/reference/rest/v4/accounts#Account.AccountRole):

- `ADMIN`
- `OWNER`
- `CO_OWNER`
- `MANAGER` or
- `COMMUNITY_MANAGER`

then I would have to make a field of type text and assign her one of those categories by typing in the appropriate text. But by making this field of type `text` I could also accidentally assign her the role `OWNE` or `COMMUNITY_MANGER` or `ANYTHINGelseByAccidentBecauseThisISjustTEXT`. Bubble wont protect me from miscategorizing.

Using categories to drive app logic is a very common design pattern and I think Bubblers would benefit alot if we could define our own categories. Because then we’d get access to them in the same way we get dropdown access to the `Yes` or `No` categories and all the errors associated with mistyping categories would be gone. Plus, if a service tried to set a category to something it can’t be (say, via API), then bubble could respond appropriately. So futuristic!

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/e/0/e02896603c98bee7c3a4bb70d5808686d379cfaf.png)

---

<div class="post-metadata">

**Author:** ![dbruehlmeier](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dbruehlmeier/32/180690_2.png) [@dbruehlmeier](https://forum.bubble.io/u/dbruehlmeier)\
**Post date:** [April 25, 2019, 9:25pm UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/2 "2019-04-25T21:25:45Z")

</div>

I totally agree. This would be very useful!

---

<div class="post-metadata">

**Author:** ![jamesbond](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jamesbond/32/40242_2.png) [@jamesbond](https://forum.bubble.io/u/jamesbond)\
**Post date:** [April 25, 2019, 9:28pm UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/3 "2019-04-25T21:28:43Z")

</div>

+1 Would be very helpful @Bubble

---

<div class="post-metadata">

**Author:** ![neerja](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/neerja/32/29814_2.png) [@neerja](https://forum.bubble.io/u/neerja)\
**Post date:** [April 25, 2019, 9:44pm UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/4 "2019-04-25T21:44:26Z")

</div>

Our engineering team will review this request.

---

<div class="post-metadata">

**Author:** ![Kfawcett](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/kfawcett/32/38097_2.png) [@Kfawcett](https://forum.bubble.io/u/Kfawcett)\
**Post date:** [April 26, 2019, 12:50am UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/5 "2019-04-26T00:50:11Z")

</div>

This is easily solved by creating a table for your categories. Let’s call it “Category”.

Then on the User table add a field called “Categories” make it of type “Category” and make it a “list”.

Then you can add to the list through the backend as a menu (you type to select a menu item, but not by typing in a value) on the User table or through workflow actions (add, remove, set list, remove list, etc.).

---

<div class="post-metadata">

**Author:** ![keith](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/keith/32/56020_2.png) [@keith](https://forum.bubble.io/u/keith)\
**Post date:** [April 26, 2019, 1:32am UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/6 "2019-04-26T01:32:45Z")

</div>

But not in the editor, which is what I think @zelus_pudding is going on about.

This is easy in one’s app, but there’s no macro type functions in the editor.

ZP’s suggestion is very similar to other ideas like having an expressions palette, etc, where one could paste and store hard-to-build, but frequently used, expressions specific to the development of one’s app.

(Faye has a similar one that was specifically about colors, but the general case here is that the editor has no facility to let you make app-specific shortcuts and stuff that would greatly speed development in some cases.)

---

<div class="post-metadata">

**Author:** ![jamesbond](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jamesbond/32/40242_2.png) [@jamesbond](https://forum.bubble.io/u/jamesbond)\
**Post date:** [April 26, 2019, 1:51am UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/7 "2019-04-26T01:51:33Z")

</div>

Far too complex for something that should be easy for Bubble to do. I’d much rather @Bubble implements it the way @zelus_pudding has suggested. It would make a huge difference.

---

<div class="post-metadata">

**Author:** ![Kfawcett](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/kfawcett/32/38097_2.png) [@Kfawcett](https://forum.bubble.io/u/Kfawcett)\
**Post date:** [April 26, 2019, 1:55am UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/8 "2019-04-26T01:55:22Z")

</div>

The use case is to “categorize a user”. It doesn’t get much simpler than what I show in the video below. This is common database design.

You can play with it here: [| Bubble Editor](https://bubble.io/page?type=page&amp;name=category_as_data_type&amp;version=test&amp;id=forumapp3&amp;tab=tabs-3)

[![](https://img.youtube.com/vi/JMm7JyWOdi4/maxresdefault.jpg "19312e10-aa91-4ade-y5a1-bb4e44a2e645.webm") ](https://www.youtube.com/watch?v=JMm7JyWOdi4)

> [@zelus\_pudding](#):
>
> For example if I want to categorize a user who fits into [one of 5 states like](https://developers.google.com/my-business/reference/rest/v4/accounts#Account.AccountRole):
> 
> - `ADMIN`
> - `OWNER`
> - `CO_OWNER`
> - `MANAGER` or
> - `COMMUNITY_MANAGER`

---

<div class="post-metadata">

**Author:** ![jamesbond](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jamesbond/32/40242_2.png) [@jamesbond](https://forum.bubble.io/u/jamesbond)\
**Post date:** [April 26, 2019, 2:01am UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/9 "2019-04-26T02:01:07Z")

</div>

Nope it’s too long for me to setup. You’re better off creating notes on the datafield with the listed values and then copying and pasting them into your conditions (which is what I’m currently doing). That method has taken you at least 2 minutes to setup.

---

<div class="post-metadata">

**Author:** ![Kfawcett](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/kfawcett/32/38097_2.png) [@Kfawcett](https://forum.bubble.io/u/Kfawcett)\
**Post date:** [April 26, 2019, 2:04am UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/10 "2019-04-26T02:04:06Z")

</div>

Not sure what you’re going on about, but the OP asked how to categorize a user without the chance of making typos as you might in a text field. The way to resolve this is to make the “values” live in a database table and reference that table from any other table as a field.

---

<div class="post-metadata">

**Author:** ![jamesbond](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jamesbond/32/40242_2.png) [@jamesbond](https://forum.bubble.io/u/jamesbond)\
**Post date:** [April 26, 2019, 2:10am UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/11 "2019-04-26T02:10:58Z")

</div>

This is the original discussion for some context.

> [@Way to make a categorical field type?](http://forum.bubble.io/t/way-to-make-a-categorical-field-type/55371/3):
>
> I appreciate that response slight_smile I knew this was possible but it’s far from ideal. The genius of having a Yes / No field is that, by bubble limiting you to the choices yes or no you can’t enter an impossible value such as YeS or nO or even maybe. If I manually track and assign these categories like you’ve suggested then I can and will accidentally type in admin or Admi instead of Admin and then my app wont work and I’ll be scratching my head for hours trying to figure out why. I wonder…

---

<div class="post-metadata">

**Author:** ![Kfawcett](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/kfawcett/32/38097_2.png) [@Kfawcett](https://forum.bubble.io/u/Kfawcett)\
**Post date:** [April 26, 2019, 2:15am UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/12 "2019-04-26T02:15:59Z")

</div>

What I provided is still the answer. You were on the rigth track for what @zelus_pudding wanted, but you made your field of type “text” instead of of type “category” – which actually means it references another table so there’s no chance of incorrectly typing something like “yEs” or “nO”, since Yes and No are already defined in your database table as “Yes” and "No.

---

<div class="post-metadata">

**Author:** ![jamesbond](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jamesbond/32/40242_2.png) [@jamesbond](https://forum.bubble.io/u/jamesbond)\
**Post date:** [April 26, 2019, 2:24am UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/13 "2019-04-26T02:24:05Z")

</div>

I’m not disputing that you’ve got a solution, I’m merely stating that having to create several tables and preloading several entries of data is time consuming. It would be much better (certainly for development speed) for Bubble to implement a boolean style feature directly in the editor.

---

<div class="post-metadata">

**Author:** ![keith](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/keith/32/56020_2.png) [@keith](https://forum.bubble.io/u/keith)\
**Post date:** [April 26, 2019, 2:30am UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/14 "2019-04-26T02:30:27Z")

</div>

Again, ZP is talking about the editor. What he’s asking for is the equivalent of autocomplete in a code editor, basically.

But in the app side, creating system variables is where it’s at. In a sophisticated app, one will have many such things that you use as dropdown values, important constants, etc. Only you the admin will create them. Users will just consume them. To speed creation of such things, you might build admin interfaces for such things rather than doing it with the suboptimal capabilities of the Data tab.

---

<div class="post-metadata">

**Author:** ![gf\_wolfer](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/gf_wolfer/32/262456_2.png) [@gf\_wolfer](https://forum.bubble.io/u/gf_wolfer)\
**Post date:** [April 26, 2019, 3:11am UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/15 "2019-04-26T03:11:01Z")

</div>

I agree with the original poster, this would be much simpler and potentially safer (as in idiot proof, not security) than storing the Text values in the Notes section, which is what I commonly do.

Webflow does a good job with this exact scenario

---

<div class="post-metadata">

**Author:** ![JonL](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@JonL](https://forum.bubble.io/u/JonL)\
**Post date:** [April 26, 2019, 8:55am UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/16 "2019-04-26T08:55:37Z")

</div>

So basically you want the editor to read from your Data Type content. What if your data type has 100000 elements?

---

<div class="post-metadata">

**Author:** ![zelus\_pudding](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/zelus_pudding/32/68250_2.png) [@zelus\_pudding](https://forum.bubble.io/u/zelus_pudding)\
**Post date:** [April 26, 2019, 4:17pm UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/17 "2019-04-26T16:17:45Z")

</div>

If I’m understanding your point correctly:

_The editor wouldn’t nicely support 100,000 elements (from both the UX perspective in that it’s hard to pick from that many drop down elements and tech perspective in that having that many drop down elements could slow down or crash the editor)_

I agree, there would be problems with supporting 100k categories.

Reasonable APIs typically don’t have more than, hmmm, let’s say 30 categories that they juggle internally for any given resource. Here are some of the most egregious examples I could find from 3 developer friendly APIs

1. Google My Business - no more than 5 categories

2. Github - no more than 11

3. Stripe - no more than 13

So the path forward is to decide on a reasonable upper limit of categories - may I suggest 15 or 20 - to where if you can’t make it work for your application, you’re just going to have to make do with 14 or 19 specific categories plus a last one for catchall. For anything remotely near the hundreds of categories nothing would change… and if you really need to work intensely with that many categories you’d be better off making a python lambda function that leveraged [pandas.categories](https://pandas.pydata.org/pandas-docs/stable/user_guide/categorical.html).

---

<div class="post-metadata">

**Author:** ![JonL](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@JonL](https://forum.bubble.io/u/JonL)\
**Post date:** [April 26, 2019, 5:01pm UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/18 "2019-04-26T17:01:56Z")

</div>

I think it justs adds constraints where they are not needed because what if I need 50 categories because I really need them.

Anyway, I do not have the problem of mistyping because I build categories based on numeric IDs/codes and not names. Sure those categories have a name field also but that is just for end users of the app.

All the logic is built around status 1, status 2 and status 3. Or user type 1 or user type 2. Yes those categories probably have names also, status active, status obsolete or status inactive. User standard and user admin.

But I can’t mistype admin as admino because for me it’s just a 1. Obviously if I write a “45” where I should write “1” it’s completely my fault for not paying the right attention.

Also another good thing of using IDs in the logic of the app and not names is that if I want to change the category name from inactive to Inactive I don’t have to go and change every single condition or expression.

Use Bubble Data Types for categories with at least 2 fields(Id and title/name/description) and use those IDs in Bubble expressions.

---

<div class="post-metadata">

**Author:** ![zelus\_pudding](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/zelus_pudding/32/68250_2.png) [@zelus\_pudding](https://forum.bubble.io/u/zelus_pudding)\
**Post date:** [April 26, 2019, 8:31pm UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/19 "2019-04-26T20:31:36Z")

</div>

That’s totally doable as well Jon. But there’s a really good reason why API’s from Google, Github and Stripe make these statuses textual - it’s _readable_ and _reasonable_. `1` is arbitrary `requires_payment_method` is not. And this requested functionality doesn’t add constraints. You’d still be free to do it as you do now.

There’d also be nothing stopping one from chaining two or more categorical data types together to trigger unique app logic. For example, one could check the values of two categorical field types (@ 15 options) to trigger up to 15 ^ 2 = 225 unique workflows. At 3 data fields that could trigger 15 ^ 3 = 3375 unique workflows, etc.

By the way thank you for the polite discourse 🙂

---

<div class="post-metadata">

**Author:** ![JonL](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@JonL](https://forum.bubble.io/u/JonL)\
**Post date:** [April 26, 2019, 8:47pm UTC](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376/20 "2019-04-26T20:47:16Z")

</div>

> [@zelus\_pudding](#):
>
> _readable_ and _reasonable_

I agree completely. But those statuses are consumed by you and I, end users of the API. For Goggle and Stripe developers they are probably using an ID.

That’s what I meant with using IDs and Names. IDs for internal use(Bubble developers) and names for consumers(my users).

I follow that approach and it’s not mutually exclusive indeed with your proposal. Just sharing my strategy 🙂

I do see some added value in your proposal in any case 🙂

[Next page](https://forum.bubble.io/t/built-in-way-to-define-categorical-data-types/55376.md?page=2)
