Lookup vs. select object and multiselect option
Posted: Sun Apr 14, 2024 7:46 pm
Hi there!
I'm setting up a new database application with nuBuilder and struggeling with a basic question (that actually I haven't noticed before, funny...): When to use a select object and when a lookup object? From a plain technical point of view, they seem to do the same: Saving a foreign key. Of course, I know that the lookup object shows more information than just a single value (as the select object does) and offers creating/editing/deleting the record of the foreign key. However, I could also open a second table and create a new record directly, which can then be chosen with in the first table via select object, couldn't I? So apart from the - let's say - "usability advantages" the lookup object offers, are there any - rather technical/basic - limitations or advantages of each object to consider, before deciding to use either lookup or select object for table relations?
To this question, I noticed that the select object offers the multiselect option for saving multiple foreign keys. I suppose, the FKs are stored in a single JSON column. First I thought this would be a great technical advantages of select objects, since I don't need to create the "third table" for n:n relations. I've searched a bit, to get more information on this very convenient solution. All in all, I've found rather negative feedback for this solution bypassing the thrid table:
First:
"Note that JSON columns can’t have a default value, be used as a primary key, be used as a foreign key, or have an index."
(https://www.sitepoint.com/use-json-data ... databases/)
Obviously, they can and it works. But regarding database architecture and normalization:
"You should not store an array of foreign keys. That's not a valid relational data design."
(from: https://stackoverflow.com/questions/713 ... -data-type)
So, I wonder a bit: When storing multiple foreign keys in a single columns is regarded as no good practice, should I use it at all? What was the idea for implementing this feature?
I'm setting up a new database application with nuBuilder and struggeling with a basic question (that actually I haven't noticed before, funny...): When to use a select object and when a lookup object? From a plain technical point of view, they seem to do the same: Saving a foreign key. Of course, I know that the lookup object shows more information than just a single value (as the select object does) and offers creating/editing/deleting the record of the foreign key. However, I could also open a second table and create a new record directly, which can then be chosen with in the first table via select object, couldn't I? So apart from the - let's say - "usability advantages" the lookup object offers, are there any - rather technical/basic - limitations or advantages of each object to consider, before deciding to use either lookup or select object for table relations?
To this question, I noticed that the select object offers the multiselect option for saving multiple foreign keys. I suppose, the FKs are stored in a single JSON column. First I thought this would be a great technical advantages of select objects, since I don't need to create the "third table" for n:n relations. I've searched a bit, to get more information on this very convenient solution. All in all, I've found rather negative feedback for this solution bypassing the thrid table:
First:
"Note that JSON columns can’t have a default value, be used as a primary key, be used as a foreign key, or have an index."
(https://www.sitepoint.com/use-json-data ... databases/)
Obviously, they can and it works. But regarding database architecture and normalization:
"You should not store an array of foreign keys. That's not a valid relational data design."
(from: https://stackoverflow.com/questions/713 ... -data-type)
So, I wonder a bit: When storing multiple foreign keys in a single columns is regarded as no good practice, should I use it at all? What was the idea for implementing this feature?