jeudi 7 mars 2019

Implement "add to favorite" in database

I have a question regarding database/system design. We have a table user with user_id and a table school with school_id. We want to implement a feature so that users can add schools to their "favorites list". I already created a third table that contains the relationship between user_id and school_id. Now I have the two following questions:

  1. When a user removes a school from "my favorites" list, should I delete it or keep it in the database but mark it as "deleted"? I want to keep it but it might leave tons of junk data in the table over time.

  2. The front-end design looks similar to like/dislike button on twitter. User can favorite/unfavorite a school with one click. Is there any good way to prevent a bot from constantly hitting the the database by clicking the button?

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire