DEV Community

Cover image for The Magic Of A Single Integer Number To Contain Huge Information
Haripriya Lekshmi
Haripriya Lekshmi

Posted on

3 3

The Magic Of A Single Integer Number To Contain Huge Information

This blog is about how we can effectively store huge pieces of information by consuming less space. For this, here taking an example of “How to store all roles of a user in a single integer value.
A programmer should write a module for handling Roles and Permissions for the users when developing an application software. Suppose we have the following roles.

The programmer will usually assign an integer ID to each role like the following:

Suppose the user with ID 1 has the roles of Data Entry and View Only.
In this case, the programmer can save user permissions in two different ways:
Create a string with roles separated by a comma, for example, 6,7 and this can be stored in the column. While retrieving back, we can split the string by comma and find the role IDs.
Each role IDs can be stored against user id by consuming each column for each role ID as follows:

In this case, we need a separate table for storing information on user roles.
Would you like to know another better way to store any combination of user roles as a single integer value?
Read our latest blog by Sukesh Chand on storing huge information in a single integer values
https://urlzs.com/7QWkj

API Trace View

How I Cut 22.3 Seconds Off an API Call with Sentry

Struggling with slow API calls? Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

Billboard image

Try REST API Generation for Snowflake

DevOps for Private APIs. Automate the building, securing, and documenting of internal/private REST APIs with built-in enterprise security on bare-metal, VMs, or containers.

  • Auto-generated live APIs mapped from Snowflake database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay