I’m still learning and in my practice app there are products as data type which has the following fields:
-name - TEXT
-logo - IMAGE
-description - TEXT
?? (-comment - List of Comments) ??
And comments as another data type has the following fields:
-body - TEXT
-votes - List of Users
?? (-product - PRODUCT) ??
Under each product (on the product page) people can post comments. My question is which approach would be better to structure my database. Comment points to its Product or Product points its Comment?
Depends, in my opinion. If you expect the list of comments to be < 30, then I’d place it as a list under Products. If you expect to have more comments, I’d keep the comments separated from the Product, and place the Product data type under a Comment.
Also, if you expect to display Products on different pages (without its comments), I’d definitely choose the latter approach.