When building the architecture of a new project, I am trying to find a good solution for dealing with public IDs.
For example, our users receive a membership card. The membership number is printed on each card. However, as we expect collaboration in our industry with other companies, the format of these member IDs may change in the future, or we will use additional IDs.
Of course, the membership ID is not the internal database primary key or the like.
These are the two options I found:
- The membership ID is a property of the user model.
- It is easy to query.
- Then, every time we have a new format, we have to change the model and the database schema.
- The membership ID has its own model that references the user model
- That's easy to expand.
- Then, however, we need to join two tables together for (more or less) each query
I know that it depends heavily on many factors for which this question is too short to mention, but it is not advisable to expect changes to the database schema rather than explicitly modeling that kind of flexibility. I mean, that will only happen once in a few years.
Or do you have other ideas?