I am wondering if I can achieve this using a postgres view (or materialized view) rather than a table.
Requirement: I need a unique ID on my view that must always belong to the same row. My first thought was a composite key - there are two integer fields in my view that when combined would be unique. However of course (52, 6) will look the same as (5, 26) when combined.
As per Is there a simple way to create a unique integer key from a two-integer composite key? it looks like a lot of complicated maths can be done to create a unique composite bigint value for a view, however I feel like this might be a bit hard to maintain.
I'm wondering if there's anything a materialized view might offer to ensure an ID is always unique and not changing, even once the view is refreshed.
I've tried Row_number() over
but that is ruled out as, although it is unique, it changes each time.
I'm currently considering just using a table to get around this issue if there is nothing simple that achieves this.