Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Is it good practice to use array/jsonb column for a non searchable, single row table?

Rails • Asked by Luca Rossi

Hi guys wanted to get some feedback on the way I have been using In my first app I am using both array (text) and jsonb columns. I am using these instead of additional DB tables since the structure in each record will be different and I do not intend to search into them.

The array text column is used to:

  • store operating hours for each store
  • store consultation appointment time slots (min length is 15 = 1 slot, so a 1 hour consultation = 4 slots). I am storing an array with the slot numbers as I need all slots when I calculate the available timeslots for new consultations (all slots - busy slots = available slots)

The JSONB columns are used to manage form templates and values:
One columns is used to store form templates created using formbuilder.js in the tforms table. The other is used to store both form and data in the actual consultation table: when a consultation is created, the template from the forms table is saved to the consultation form column. From this point on every time the consultation is accessed the form and inputs are accessed/saved in the local column. This way the form template can be modified for future consultations and the old data is preserved (i need to add a function that allows users to add newly added fields to existing consultations if required).

All works fine for now on the prototype. However, I wonder if anyone would have done things in a different way..

Thanks in advance for your time!


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,242+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.