Moderator
You mean to save other people's name and birthday?
Votes
0
Replies
24
Participants
Unknown
Messages
25
Moderator
You mean to save other people's name and birthday?
Rank 1: Thread
Exactly 💯
Moderator
Will such users be registered in the app or you add others that don't have an account associated?
Rank 1: Thread
Only the user that is adding the names and birthdays will have an account.
Moderator
Okay, then you can use both methods. There's not any major difference, maybe if you're going t have the ability to share in a future all birthdays an user has or other users will search other users saved birthdays it could be more convenient having everything in one collection, but if everything will remain as is, there's not a "better" approach.
As said, personally I prefer just having a collection for everything, but it's just a personal choice
Rank 1: Thread
I don't think there will not be a usecase where other users can search another users birthday list.
It's only that user that should/will be able to view their birthday lists.
Rank 1: Thread
The model looks feasible but I don't know how to go about it in appwrite
Moderator
Method 1:
Create a collection for each user: collection ID = user ID
Method 2 (what I do most times):
Collection named birthdays
Attribute called User ID: here you store creator ID
Then you fetch all documents with the User ID = current user ID
Rank 1: Thread
For method 1: Can I programmically create a collection?
Rank 1: Thread
For method 2. Does this mean that all users will be using the same birthday collections which will have an attribute for user_id which I will use to query/filter with to get all the birthdays that belong to that user?
Moderator
Only with functions
Moderator
But in method 2 you will need too functions
I think it's still possible to use Relationships, but it's still beta
https://medium.com/geekculture/appwrite-frequently-asked-questions-374ce81513fe?sk=58820ac7b3372fad404e822b79f9b849 then search for database design
I would go with method 2. That's what the article suggests. Using document level permissions, a user would only get their documents
Rank 1: Thread
Okay, thank you
Rank 1: Thread
So by setting permissions to access that doc to the user that created it, I am able to have numerous documents in the birthday collection but they can only be accessed by their creators.
This then leads me to another question, Can I programmatically set permissions when creating a doc?
Yes you can. By default, the creator will be given read, update, and delete, but you can pass whatever permissions you want. See https://appwrite.io/docs/permissions
Rank 1: Thread
Alright, thank you Steven. I will get back to you when I create the model and test it out.
Another question, is there a limit to the number of documents a collection can have?
I think it's 74TB of data
Moderator
I've thought there was not any hard limits. What's happens if I reach 74TB (okay, better not to dream 😆)
It's mariadb max table size
Moderator
I think that's enough for my projects and most 😅
Rank 1: Thread
Alright, thank you.
Rank 1: Thread
[Solved] Need help with creating database model