I'm trying to create an ERD based on the FE mockups here: https://imgur.com/a/E3XJ0OU.
It's a multi-tenant database where a tenant represents a company. Azure AD is used for authentication. There are three-types of notifications: In-App,
The "Administrator Settings" screen that you can see on the images, is all about the tenant administrator being able to enable/disable event types globally for every user in the tenant.
"Notification settings" screen is where the user can see only the event types that the tenant administrator has enabled and enable/disable them for himself.
Am I going in a good direction with the ERD? You can preview the ERD in an online Mermaid editor.
Tenant
- TenantId (primary key)
- Name
User
- UserId (primary key)
- TenantId (foreign key to Tenant table)
- Phone
Event
The Event table represents the different types of events for which notifications can be sent. It could be the different stages of an offer: Offer Filled, Offer Completed, Offer Cancelled, Offer Rejected, Offer Expired.
- EventId (primary key)
- EventName
AlertTone
- AlertToneId (primary key)
- AlertToneName
- AlertToneUrl
UserEventNotification
For each user, we can store their individual preferences for event notification types in the UserEventNotification table. This table also includes the user's chosen alert tone for each event type. The XEnabled column allows users to enable/disable notification types for specific events, but only for those events that were enabled by the administrator in the GlobalEventNotification table.
- UserEventNotificationId (primary key)
- UserId (foreign key to User table)
- EventId (foreign key to Event table)
- InAppNotificationEnabled (boolean, whether in-app notification is enabled for this user and event)
- EmailNotificationEnabled (boolean, whether email notification is enabled for this user and event)
- SmsNotificationEnabled (boolean, whether SMS notification is enabled for this user and event)
- AlertToneId (foreign key to AlertTone table)
GlobalEventNotification
- GlobalEventNotificationId (primary key)
- EventId (foreign key to Event table)
- InAppNotificationEnabled
- EmailNotificationEnabled
- SmsNotificationEnabled
erDiagram
User ||--o{ UserEventNotification : "has"
Tenant ||--o{ User : "has"
UserEventNotification ||--|{ Event : "for"
UserEventNotification ||--o{ AlertTone : "uses"
GlobalNotificationType ||--o{ Event : "for"
User {
string UserId
string Email
string Phone
string TenantId
}
Tenant {
string TenantId
string Name
}
Event {
string EventId
string EventName
}
AlertTone {
string AlertToneId
string AlertToneName
string AlertToneUrl
}
UserEventNotification {
string UserEventNotificationId
string UserId
string EventId
boolean InAppNotification
boolean EmailNotification
boolean SmsNotification
string AlertToneId
}
GlobalNotificationType {
string GlobalNotificationTypeId
string EventId
boolean InAppNotification
boolean EmailNotification
boolean SmsNotification
}