This is really DB related. Should I use the built in DB logic from mysql? I mean I could just design my tables without their relation, thats it.
Example: I got a DB with:
t_user
t_images
t_posts
so i have my 3 tables and now when I delete a user in table t_user all his referenced rows in t_images assigned to him should also be deleted. So I could do that with DB engine or also with Wappler.
But here comes the problem: As I’m having only a link source to my pictures in t_images with my DB built in system the depending rows would be deleted, but of course not any files or pics in the filesystem. So that means anway I need to handle delete stuff in Wappler. And now comes my point: If I NEED to take care about delete stuff, should I go with these DB relations and foreign keys???
I mean I can set in mysql DB on my table t_user that when a user with ID 423 will be deleted, then his referenced rows in t_images with id 423 will also be “deleted”. (I see options like: this)
@ben I guess you’re the right guy for this. How much you handle ON DB side and how much in Wappler? Whats your best practice before I go with a project? Thanx so much
If it were me I still use the DB foreign keys for relational DB design with onupdate and ondelete cascade however I would then have to manually have the delete action in Wappler also remove the image/s that belong to the record.
Only other way is to have a script run once a week or something on schedule that deletes whatever images from whatever folders if they do not exist in the database table for image paths.
Sorry I have to go the bottle store now, will be back to explain more if needed in about 20 minutes.
Yes, i think with images it is probably going to have to be a repeat region to remove the images BEFORE the table entries are removed or the pointers will be removed before the images as would happen with a cascade delete. I try to use a folder structure for images linked to the ID of the record so if the record is deleted, the folder can be removed in a single action, quicker than a repeat through them all
@Freddy_Blockchain, you have @Hyperbytes helping now, i will bow out gracefully, you are in good hands, he is the database guy i go to for help all the time.
A user can be in multiple groups and a group can have multiple users, that’s a many to many relation, so you need an extra table for it with user_id and group_id in it.
Ok got that with that helptable, already use that for n:n relations or many to many. But with assigning I meant more that: https://www.jqueryscript.net/demo/Dynamic-Autocomplete-Tag-Input-Plugin-For-jQuery-Tokenize2/
Sorry for mixing up questions here, as this is a new question I’m not sure how to handle these groups so when I’ve added for example Audi and BWM, that shouldn’t appear again from my autosuggest.
I am not sure if this answers your question. I am in the process of creating a tutorial to create an image gallery. This is what I have for deleting a gallery
When I have used Gallery, this could easily be user, or motor vehicle or real-estate.
Images need to be removed from the images table as well as physically from the folder. I have a folder named using the galleryID (userID) as follows /galleries/galleryID
Using the galleryID I remove all of the images from the table and remove the complete containing the images.