Database structure for posts

Hi everybody,

I am learning how to structure databases on Bubble. There is an article on bubble.io that shows the database structure for a Facebook clone.

There is the information for the posts:

“Data Type: Post - messages that Users write, to be read by other Users
Fields: creator (field type User; included by default), date created (included by default), message”

In this context, I have a few questions

  1. Does this mean that all posts of all users will be “collected” in the same database?
  2. So, in order to show the post of a certain user, it is necessary to have relevant rules in the application, which will select only messages of this user from the post database?
  3. How to use this structure to keep historical data for each post? For example, to make an “undo” function?

Best regards
Alex

Hope that helps,

Tal
nocodify.com

1 Like

Hi Tal,

thank you very much for your answers!

It means, if we have 100 users, each one writes 10 messages a day, then 1000 messages will be registered in the database per day. And 30,000 in a month. Won’t bubble have any problems with performance?

I can imagine that the “filtering” process will be slower with each month. Or am I wrong?

One more question - how much does it make sense to make a separate database of posts for each user?

Best regards
Alex

Yes, the performance will get worse. This is why you want to relate data types to each other to lower the # of searched on tables.

So for example, taking Instagram as an example, you’d have a “post” data type which refers to the User uploading an image/video.

Then, you’d have a separate data type called “Comment”. When a User comments on a post, you’d relate that comment to the post. So the post data type would have a data field for comments (list of comments).

Then, when you’re displaying comments for a post, you can just do “This posts comments”. So in terms of performance, bubble just shows the comments associated with that post, instead of searching through every single comment created.

Hope that helps,

Tal

1 Like

Hi Tal,

do you mean we make a separate databases for each “type of information” and connect them by creating logical linking in the application?

This raises another question :slight_smile: If we make a separate database of posts and comments, the speed of the application should still slow down, because there are more of them and bubble needs more resources to analyze the connection between databases (data types) and the information in these databases.

For example, we have two types of data:

  1. Users - 10 people
  2. Posts - 10 for every user
  3. Comments - 30 for each post.

In this case Bubble should analyze and connect together information about 3,000 stored items.

If the number of users increases to 100, the amount of analyzed information will increase to 30,000 items. Does it mean that the application will work 10 times slower?

Are there any options for data clustering and analyzing it in a smaller amount, but in a multithreaded way?

Best regards,
Alex