DB Schema - Notification Service
I'm a little stuck with the database schema for an application I'm building and was wondering if anyone could give some advice?
Basically, I want to allow users to subscribe to certain events using a variety of services. For example..
When Event A is fired, it would send notifications via all methods that were subscribed. This might be 1 email address, 2 emails addresses, a Slack channel, a POST request to a URL, A tweet to Twitter or all of them.
An event is only ever run once. But, if this could be structured in such a way it supports an event running multiple times that would be even better.
I was thinking something like this:
| --------------------------------------------|
| Subscriptions |
| --------------------------------------------|
| id | Primary Key |
| event_id | ID of event subscribed to |
| sub_id | Object ID |
| sub_type | Polymorphic Type |
| --------------------------------------------|
| --------------------------------------------|
| Email |
| --------------------------------------------|
| id | Primary Key |
| address | Email Address |
| --------------------------------------------|
| --------------------------------------------|
| Webhooks |
| --------------------------------------------|
| id | Primary Key |
| type | Post or Get request |
| url | URL to trigger |
| --------------------------------------------|
| --------------------------------------------|
| Twitter |
| --------------------------------------------|
| id | Primary key |
| auth_id | Foreign ID for Auth table |
| type | DM or Tweet. |
| --------------------------------------------|
Please or to participate in this conversation.