0

I was recently thinking which way is the best to store bookmarks and thought i will ask this question on here:

Method 1(this is the simple and most used way):

+-------------------+
| bookmarks_users   |
|-------------------|
| id (int, primary) |
| user_id (int)     |
| bookmark_id (int) |
+-------------------+

Method 2:

+-------------------+
| bookmarks_users   |
|-------------------|
| id (int, primary) |
| user_id (int)     |
| bookmarks_ids (int) |
+-------------------+

but instead of having it multiple we can have one row per user and each time they add a bookmark we can just put it in bookmarks_ids so it will look like this 1,21,35,223,677,345,653,566,244 and on the user side we can just use php to split them based on the , and then fetch all the posts via another function

5
  • @mustaccio Hay, nice thanks for sharing this info with me.
    – DB_cont
    Dec 16, 2021 at 13:24
  • Can a bookmark be shared between users?
    – Rick James
    Dec 16, 2021 at 21:47
  • @RickJames well generally from what I see bookmarks are more of a personal thing rather than sharing but it might be a good feature to implement
    – DB_cont
    Dec 17, 2021 at 6:51
  • you will just have to create a duplicate of the bookmarks and assign the user_id to who you are sharing to.
    – DB_cont
    Dec 17, 2021 at 6:52
  • The Bookmarks table would have a user_id and the info about the bookmark. This is the "many-to-one" pattern. There is no extra table; that is for many-to-many.
    – Rick James
    Dec 17, 2021 at 18:01

0

Browse other questions tagged or ask your own question.