What's the best answerOrexercise for situation such as this? I've got a table, that may mention of the multiple tables (objects)?

Here's a good example for any table UserCalendar. It is a table where user saves his event, but additionally system card inserts within this table from behind. User executes some services, that have due dates and individuals are placed within this table also. Issue is that there's no this type of table as UserEvent table. User should save all his occasions within this calendar as description. I ought to get this to simple as you possibly can.

I'm able to design this two-way.


UserCalendarId UserId Description ObjectType ObjectId

By using this option I wouldn't need to FK this tables. I possibly could just have to change ObjectType (Notification,Service,Calendar) and employ id of this Table as ObjectId. Just in case of Event there won't be any this type of Table and this is null area. We an refer to this as pseudo FK column.

2) Or I possibly could use as states theoretically with multiple tables for every FK.

UserCalendarId UserId Description

UserCalendarId EventId


UserCalendarId NotificationId

This foreign associations tables could be a n number, for every system event or other custom event that goes to particular type

First option would be a quick implementation.

I'd should you prefer a 3rd solution as a mixture of your two designs:

UserCalendarId UserId Description

UserCalendarId ObjectType ObjectId

By doing this you're liberated to add as numerous additional references for your calendar entry as you want (e. g. event and notification) and you do not have a good coupling between your UserCalendar table and then any other tables.

Additionally, it is dependent a bit how frequently you need to access that additional data (occasions, service, etc.) if it seems sensible to place the FK inside your primary UserCalendar table.

I would recommend opting for versatility a lot more than for performance, if you will slightly boost the complexity of the schema. It's much more likely which include needs can change than you'll be hit by performance problems.