Skip to content
Advertisement

APEX get Multiple entries FK

,i dont know what so search for my problem. I think its very simple, but i dont know about that 🙂

I have a Table where i listed all my “Groups/Teams”

And then i have a Users Table where i list all the People:

I use APEX 18.1 and have a Form with a List of Values, there i can select one of the Groups i have added at the other Table…

So my question is, how i can assign more Groups to one User? Do i need to add more FK Columns? or can i store like multiple IDs 1;2;3; etc..

Best case would be a form where i can select one Group, then klick a “Plus” and select anotherone..

i hope you understand what i wanted to say

Thanks for your help

Best Regards Daniel

Advertisement

Answer

Apex offers Select List (as well as Shuttle) items that allow multiple selection. If you store such values into a database column, they will be stored as colon-separated values. For example, if you choose Roma, Juventus and Inter, they will be stored as Roma:Juventus:Inter (actually, their return values, which would then be some IDs, such as 23:8846:2231). No problem with that, you have what you wanted.

However, such a principle reads good night, normalization as you can’t do much with that. If you ever wanted to display values hidden behind such a list of stored IDs, you’ll have to split that string into rows and join it with the master table. That’s not impossible, of course, but requires some coding. For example:

What’s worse is that – if anyone manually edits such a column value, they can enter invalid IDs that don’t exist in the master table. In other words, no referential integrity is maintained.

Therefore, although you can do that, I don’t suggest to do it.

Usual way of handling such situations is to create a new table which contains pairs of values, e.g.

  • foreign key constraints will make sure that you can’t enter invalid values for users nor teams
  • primary key constraint makes sure that you can’t have duplicates

In Apex, you could choose an Interactive Grid to handle such a situation, as it allows you to enter as many rows as you want (simply by pressing the “Add row” button).

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement