Single table relationship with multiple tables

Hi ,

Is it possible to relate a single table with multiple tables like i have user, event and image table and i want to save both user and event images in image table. is it possible if yes then how can we model this in GORM. and if its not possible then whats the best work around ?

Thanks

Hi @muhammad.habib! You can definitely model something like that in SQL. When you read from the image table, you just need to know the “key” you want to look for. However, it might be better if you had two tables: user images and event images, that way you’d be able to more reliably model the relationships through foreign key constraints or something similar.

As for modeling that in GORM, that’s something you might want to ask on Stack Overflow or on a GORM-related forum.