Reputation: 37
1) Is it better to structure the database :
blogapp
-User
id
name
...
-Post
id
users
-a unique id
-userId
-contentOfPost
2) Use a seperate node for UserPost
blogapp
-User
...
-Post
-UserPost
-unique id
-userId
-PostId
Thank you
Upvotes: 1
Views: 913
Reputation: 80934
Yes use a seperate UserPost
:
Users
userid
name: userx
email: [email protected]
userid1
name:usery
email: [email protected]
UserPost
userid
author:userx
postcontent: content_here
posttitle: title_here
userid1
author: usery
postcontent: content_here
posttitle: title_here
more info here:
https://firebase.googleblog.com/2013/04/denormalizing-your-data-is-normal.html
Upvotes: 2