Forum Documentation Showcase Pricing Learn more

How to add comments to a specific post?


#1

I want to implement a simple system where users can post comments on a Book review. Right now what I have implemented leads to the situation where every Review has all the same comments being displayed. So I need to figure out how to display comments for only that specific Review post.

I have the Review data type with these fields:

And I have the UserComment data type with this data structure:

The workflows for both are just “Create a new Review” & “Create a new UserComment”. How do I connect a UserComment to a specific Review so that I can display them in a RG correctly.


#2

@akhyyl - welcome to Bubble. What you’re exploring are the basic concepts of a relational database. More specifically, a relational database allows you to create associations by linking together data points.

For example, with your app, you already have three of the primary data types you need (User, UserComment and Review). Bubble does some heavy lifting for you by saving the database fields of when something was created, last modified and who created it. (For example, when a user creates a review, you automatically know which user created it, because Bubble saves that for you).

However, Bubble doesn’t know the secondary relationships. That’s where your programming comes in - you’re creating the relationships between data types. For example, on a “UserComment”, you would create a new “Field” which has the data type of “Review”. Then, when the “UserComment” is created, you also reference the parent “Review” (Conversely, you can create a field called “Associated_Comments” on the data type “Review”, which is a list of all of the “UserComments”

I recommend checking out my LearnTo lesson on “How to build a grocery list app”. It’ll give you a good understanding of how to get the basics of a database set up.


Dan (creator of LearnTo - 15+ hours of Bubble tutorials and live coaching)


#3

Thanks Dan.

This is the bit I am struggling with. I had already created a field “Review” under the UserComment data type but can’t seem to find a way to reference the parent “Review” when the “UserComment” is created. Can you maybe direct me how to?


#4

@akhyyl - have you had a chance to watch the video I linked to? It should cover how to reference a parent thing in a few instances there. (Though if it isn’t clear there, I’ll write up a response here).


#5

@dan1 Seems the video is only available to paid subscribers?


#6

Apologies, thought I’d inserted a link. Here you go:


#8

Thanks for the feedback. If you’re finding yourself stuck on some of the points in this video, I recommend working through all of the Bubble tutorials first, if you haven’t done so already.

You can also view this video directly in Youtube and make it fullscreen / increase the video quality to 1080p (HD). That should make it easier to follow along.