oscarb / flowlist

A read it sooner list populated by your friends
MIT License
2 stars 1 forks source link

Database design #5

Open oscarb opened 7 years ago

oscarb commented 7 years ago

The database needs to be designed to efficiently support queries such as:

Less priority but still of value would be the possibility to:

oscarb commented 7 years ago

Relational database

Suggested tables for a relational database

User

id phoneNumberHash

Share

id timestamp fromUser linkId

User_Share

id shareId toUser category

Archive

id shareId toUser category archivedTime

Link

id url title suggestedCategory hits

AudioLink

id type artist duration provider

VideoLink

id type channel duration provider

ArticleLink

id type author readTime provider
oscarb commented 7 years ago

NoSQL

Suggested structure for JSON documents.

User

{ id: 1,
  phoneNumberHash: 'a7fc6d998e889acf779',
  links: [ 
     {linkId: '54', sharedByUser: 5, timestamp: 4657894},
     {linkId: '37', sharedByUser: 8, timestamp: 1325489}
   ],
   archivedLinks: [ 
     {linkId: '12', sharedByUser: 5, timestamp: 4657894, archivedTime: 7894563},
     {linkId: '78', sharedByUser: 9, timestamp: 8798453, archivedTime: 4654213}
   ],
   sharedLinks: {
      {linkId: '12', timestamp: 4657894, sentToUsers: [{userId: 7}, {userId: 9}, {userId=23}]}
   ]
}
...

Link

{ id: 12,
  title: "Epic fails of summer 2016",
  url; "https://youtube.com/watch?v=4a5a3c45d",
  videoDuration: 64,
  provider: 'YouTube',
  suggestedCategory: 'watch'
  hits: 455
}
...