Data structure and management question

I am struggling with how best to structure my app data to be flexible while also not being, well, messy. A short generic description:

-There are two primary objects: Blocks of data, and collections of blocks
-Blocks are shared between users and can be added to user owned collections
-A block can be edited by the owner user, but if edited the version of the block in an existing collection must not change
-Blocks that are removed from a collection must not be destroyed

The approach I’m considering is following this flow:
A block is created > A collection is created > When a block is “added to a collection” it is duplicated and flagged as a copy within the collection

The main issue I’m having with this approach is this:
-The originating user edits the original block
-The Collection user has previously added that block to a collection, and removes it

In the above scenario the “original” block that was in the collection no longer exists.

The ugly approach to this is to simply create a copy every time an item is added to a collection, but this gets messy as a single item could potentially be added to a collection tens or hundreds of times.

Does anyone have any insight into how to solve this? I’ve considered a “published” state that can’t be edited, I’ve considered ignoring the scenario where a block simply disappears and simply copying the block data directly to the collection. None of them seem “right”. I’m not a database dev by trade so this might be a simple problem that an experienced developer would know how to solve, so please forgive me if that’s the case! Any help is greatly appreciated!

Hey friend,

FUN concept.

You have a glitch in yer matrix.

Try this on fer size…

Each ‘dataBlock’ item exists in the Bubble database only ONCE…
Go ahead an tweak a block, sure that makes a copy, which also exists only ONCE in the DB.

Users exists amirite?
Users may have x collections.
Users ‘add’ blocks to their collections in NAME ONLY. Brah, you ain’t gotta go duplicating blocks… just insert a pointer into a collection that points to the original.

I suggest those Blocks people are cookin up live in the Database with a note as to WHO Created em… That way, you don’t need to list something as a copy. If you ain’t the creater, you’ve got yer paws on a “copy”… However, it ain’t no copy, the adoptive user is settin their sights on the same durned item in the database.

Are you feelin what I’m puttin down?

That is a lovely idea Jason.

I love these fundamental discussions of data storage. They are important for all of us.

It takes time for us to wrap our heads around concepts… We just need to keep playing with the ideas until they simmer in a right tasty digital stew of elegance and insight.



Happy Bubblin!

Yes, the referencing model you’ve described is the simplest implementation, but it doesn’t account for changes:

User 1 creates a block
User 2 adds user 1’s block to their collection
User 1 edits their block
User 2 now sees edited version of block in their collection, but expected to see original.

The problem with referencing is that User 2 commits to a specific version of a block. User 1 could make any edit they want, up to and including replacing all of the content of the block. User 2 has chosen the original, and it no longer exists as expected.

Right now I’m leaning toward a permanence model to deal with this problem. Once the user is happy with a block they “publish” it, making it public and locking it’s state forever. There are problems with that too…

like this?

You’d do well to use 4 objects:

  1. user
  2. block
  3. collection
  4. contract

With this, just use one original block. Anyone that wants a copy of that block makes a contract. Wanna change a block? Make a new block and a new contract to attach it to the right collection. Then delete the previous contract. I made a mockup to demonstrate.

Try dragging an item (block) into another section and change the original. It works fine. There’s only one original of each block as you can see on the right.


Some weirdo was posting inappropriate things… Please pm me for the password.

1 Like

That is awesome! Thank you for the example.

1 Like


Happy Bubblin.