Attribute Pattern

Is there a negative impact to using the Attribute Pattern?

Example: I have accounts, each of which references 3 users:

    "_id": "<objectId>",
    "user_master_id": "<string>",
    "user_player_id": "<string>",
    "user_slave_id": "<string>"

100% of accounts have all three and only three users. However, some users are not represented in an account.

Determining if a user is “orphaned” (not in any account) requires 3 separate queries (I believe). “Orphaned” users are an ongoing problem.

I could convert the schema to an Attribute Pattern:

    "_id": "<objectId>",
    "users": [
        { "k": "<string>", "v": "<string>" }

What would be the drawback of refactoring my solution to use the Attribute Pattern - given that the solution is actually in production?

Hi again @gnumskull,

This to me looks like a bridge table? A follow-up to your other thread perhaps?

Can you perhaps elaborate with a visual example?

And have you finished the course? The course explores a host of other patterns and provides some advice on anti patterns too.

1 Like

The schema versioning pattern lesson should give you a lot of information on how you can do the migration.
You start by modifying the application to support both schemas, then migrate your data.
If the migration of the data is onlya few minutes, found a window to do the upgrade. If you can’t find a window to have downtime, then ensure the queries work across both types of schemas so they work in the migration period.

Good luck,