I am little bit confuse for creating database structure with optimize solution. Currently I am using laravel framework with laravel spatie media library and Imagga API [That is used for getting tags from image like paper, pen, face etc.]
Requirement
- There are multiple posts for users with multiple images in a post. In that if one user see the one image from the post then we need to store tags for that user.
- Now if user scroll down then show more posts related to that saved tags. Just like we have in instagram, facebook (infinite scrolling) like that.
While fetching the tags from Imagga API, It give response like this,
"tags": [
{
"confidence": 100,
"tag": {
"en": "beard"
}
},
{
"confidence": 63.3023147583008,
"tag": {
"en": "man"
}
},
{
"confidence": 55.4426231384277,
"tag": {
"en": "male"
}
},
..........
So for that I have created database as per my knowledge but I think that is not enough and might be problem with data redundancy and duplication posts while scrolling.
I am using spatie media library so there is by default table,
media table
***********
id, model_id, model_type, collection_name ...
showcase_posts table
********************
id, user_id, description, ....
media_tags table
****************
id, media_id, tag_name, confidence(accuracy of tag)
user_tags table
***************
id, user_id, media_tag_ids [JSON array with accuracy]
In that case this database structure is correct or not?
If this is correct then how I will fetch posts based on user tags with accuracy?