So before when I wrote all this code I wasn’t really thinking and set it up to do most everything as far as verifying the snake, looking it up, etc by using the name and owner. Now that I think I might want to have a concept of multiple same snake names potentially I am thinking I should be using the datatable row ID for everything and then ensuring the owner is the logged in user.
Is this the right approach or should I stick to having the name field be unique you think? I can think of where someone might have similiar names or something potentially and it would still create it the way I have it atm because it just creates it as a new record, but this would break my logic in some of my code looking at snake name, for example since it wouldn’t be unique anymore.
That make sense? Just curious what the thoughts are from others that have been using this longer than me.
You could consider the following approaches:
I maintain a portal where users are associated with multiple media resources as well as multiple roles. This is all handled by using links between tables (the first bullet point above). With this approach, it makes it very easy to set and get the connections that are associated with any user (without having to maintain explicit IDs).
There are many approaches that could work and certainly I do rely on get_id()
as well as UUIDs in other applications. This is just what comes to mind based on your description.
1 Like
Yea I’m doing links already I guess I would just have to use my own id approach so I can have something consistent potentially. Although in this case I don’t think I’ll need duplicate snake names so it should be fine using snake name per user/owner.
So a owner can have unique names pets but another user can have the same name as well, etc.
Thanks for the info.
I’m not familiar with the specifics of your application (how snakes, owners, and other entities relate); however, it sounds like you are asking about how best to manage relationships between tables. If you feel UUIDs are the best way for you, that is a perfectly fine approach from a technical standpoint.
It was less about the table relationship and more if I should really use the ID field as the main identifier but from what you have said and me thinking I think my name will just be my unique identifier in this case. I can’t think where a user would need more than one snake named the same thing.
Yeah, no one has two pets with the same name, that would be weird . So as long as a users cannot accidentally create a snake with a duplicated name then it seems totally fine.
yea I’ll add that logic into my server calls.
1 Like