In the past, I have found that with a proper design review this is not necessary. For example, an account can have many projects. An account can have many people. A project can have many tasks. Therefore, tasks apply only to projects.
If this does not really work, you can consider a task table for each type. Project Tasks, Account Tasks, etc. This will improve query performance.
Then you need the domain rule to ensure that all of your task tables adhere to a specific pattern.
I learned about the domain rule in college, but did not implement it in the real world, so I do not know how to do this on the SQL server. In real scenarios, it always worked, as I indicated in the first paragraph.
Hope this helps. Otherwise, the other two answers make sense here.
Joe c source share