Unique database table entry requiring the combination of 3 fields

Hello. I have a table in my database that contains a list of events. Each line in this table represents a unique event but the only way to refer to a single event requires bringing together 3 fields (year, country, distance). I don’t want to use the unique id as the link with other tables as it is not understandable by a human so I am concatenating these 3 fields into a 4th called event name and then using it as the key to link with other tables. Is that the right way to do this? Or is there a better way? Thanks

Hey @stephanegroud :wave:

That is one possibility, although I am not sure why you would want to do that. You would have to do a search each time you try to look for that event. If you need to view the field from the front end, you would just display the event name, otherwise from the backend if you need to have it human readable you can change the primary display field here. :point_down:

But yes, that is one way of doing it. :blush: Either way could work. Just not sure if the privacy rules will be easy to work out that way.

Thanks for taking the time to reply. That’s the catch, event name is a field that doesn’t exist per se. I am creating it artificially by concatenating 3 other fields values but I don’t like it as it is extra work and prone to error. I was wondering if there was another way. Thanks

:thinking: Good question. I am sure there is another way. Are you uploading these values from a csv? I am just trying to figure out why you don’t have the field that you need from the start.

1 Like

I don’t need it per se as a data point. Will keep thinking about this. Thanks for your input

1 Like

@J805 Has an excellent point.

You could be concatenating the three tables and perhaps use the last 4 or 6 digits of a Unix timestamp which brings uniqueness. I am thinking something like yearCountryDistanceUnixTimeStamp 2024-US-100-6789

You could save this at the moment of creation of the entry and label it “smartName” in a text field. All. your entries would be unique and readable.

And goes without saying that you could set this field as the primary field of the data type.

1 Like