I am working on a project which will have a recommendation system and I am in the database design phase, I have a good foundation in programming but databases is a new topic for me, I have designed a database but I don't really know if it's good or not.
but mainly the database should serve the following:
- store users data (including their preferences and the photos they have liked)
- store photos data (alongside with it's tags which will be used in the recommendation system)
the recommendation system will recommend content based photos so my plan is:
- fetch the liked photos of the user
- fetch the tags of each photo
- find the top 10 similar photos using cosine similarity for each photo he have liked
- store them in a new table (haven't been created in the diagram yet)
I want to know if the database that I have designed is good or I should work on it, also is there is a better approach for the recommendation system?
-
What is "user-preferences" for in the above context? Where does "item_id" come from? What happens when you delete a user? How to ensure that Photo-Tags are not duplicate?NoChance– NoChance2023年02月14日 20:56:04 +00:00Commented Feb 14, 2023 at 20:56
1 Answer 1
It's a lot better now. Simpler than it was before, which is always good.
I still have some remarks:
The table named
tag
is probably meant to attach meaning to a photo through atype
andname
. That's fine, but why do you refer to rows in that table withitem_id
? Is a tag an item? And if it is, why not call the tableitem
? I think you intend to saytag_id
instead ofitem_id
.Do photos need a
title
when they already have tags? Perhaps they do, but it is something to consider. You don't want repeated content in your database.You've got to understand what you've got now, and visually organize your tables accordingly. You've got 3 tables that contain entities:
user
,tag
andphoto
, and there are 3 tables that serve as a link between these entities:user_preferences
to linkuser
andtag
,liked_photo
to linkuser
andphoto
, and finallyphoto_tag
to linkphoto
andtag
. An argument can be made to renameuser_preferences
touser_tag
andliked_photo
touser_photo
, to make the naming of tables consistent.Now that you know that the tables
user_preferences
,liked_photo
andphoto_tag
are of the same type you can treat them in the same way. For instance, you have added a column calledscore
to theuser_preferences
table. I assume this is some kind of weight indicating the strength of the preference. Why then, if a user can also prefer a photo, doesn't that have its own score column? The same is true for thephoto_tag
table, some tags might better describe what's in a photo than others. No matter what you decide now, it should be a choice for which you have good reasons.
As I said at the beginning, this is a big improvement. Time to fill the tables with data and code the interface. I'm sure you'll still have many hurdles to take, but that's the best way to learn.
-
* At the begging I have named the table items, so I refered to it's rows with item_id and after that I have decided that the tag name will be more convinient, so I renamed it and forgot to rename the refered row, that's a good remark. *Each photo should have a title alongside with it's tags of course yes, it's not duplicated ( I have read more about on database normalization as you have said to me last question ;) ). *I have seen that people sometimes recommend to name the linking table with the name of the tables they are linking, but also other people recommend naming it with what it holdPixD– PixD2022年05月19日 12:20:30 +00:00Commented May 19, 2022 at 12:20
Explore related questions
See similar questions with these tags.