Skip to content

Tag: postgresql

Constraint on size of array type in Postgres

I have the following schema for a table (simplified for the sake of discussion) : A task transitions from NOT_SOLVED TO SOLVED when array_length(current_solved_by) == max_solved_by Questions: Is it a good practice to maintain another column, in this case state, which can be derived from other data (Based on s…

How to condense returned rows of users with multiple roles

I’m trying to wrap my head around this logic, but simply having a tough time. While trying to keep the database normalized, users can have multiple roles (example shows 2, but could have more than 2, currently have 6 total roles), and I’d like to return data to make it easily viewed on a front end UI. Tables …