You are working on a product where a user can have multiple accounts, and each account can receive notifications.
Assume the following schemas:
users
user_id
BIGINT PRIMARY KEY
created_at
TIMESTAMP
accounts
account_id
BIGINT PRIMARY KEY
user_id
BIGINT NOT NULL REFERENCES
users(user_id)
created_at
TIMESTAMP
notifications
notification_id
BIGINT PRIMARY KEY
account_id
BIGINT NOT NULL REFERENCES
accounts(account_id)
created_at
TIMESTAMP
is_read
BOOLEAN --
FALSE
means unread
account_bucket
,
num_users
.
pct_users_with_unread
(as a percent or decimal; specify which you choose).