Hi, I’m using Postgresql with Primsa.
I need some help with the best way to design my database. More details inside the thread.
Manish
03/15/2021, 2:41 AM
At it’s core, my webapp has an entity which I refer to as a collection of items - think “10 Must Read Books on Space Travel”.
Here the an item is a ‘book on space’ travel, and a collection is a list of 10 such items, in this case books.
So, I have the following tables:
Collections
Id
Name
itemId
Author (need help on this field)
Items
Id
Name
Description
<Other Fields>
Users
Id
Name
Email
<Other fields>
Manish
03/15/2021, 2:41 AM
Problem 1:
A user can login and start a new collection. This user is the owner of this collection. However, he can invite/allow other users to collaborate on this list, which means that other users can add items to it. This means that the collection now has multiple users working on it. What’s the best way to model this? How do I add multiple users for the collection (probably with different roles).
Problem 2:
The normal users viewing the collection can upvote items in the collection and the order of the items in the collection is determined by the number of upvotes. What’s the best way to store the upvotes?
Manish
03/15/2021, 7:47 AM
Problem 1: One way I though was to keep the author separate and setup a collaborators field with many to many relationship. Is it a good idea?
l
Levi Lawliet
03/15/2021, 10:16 AM
This is classic example, you can refer to here. Moreover, you can see the excellent documentation of Prisma.
Levi Lawliet
03/15/2021, 10:17 AM
This should give you a good start. Also, check out the Prisma GitRep. It should be helpful too.
Levi Lawliet
03/15/2021, 10:18 AM
I am also working on Different roles issue, but if you Google, around you can find a lot of resources on it. Try surfing StackOverflow