Question

Which one is better (Pros and Cons) (Maintenance, Extensibility) :

1.Has a Request entity have 3 different reference (navigation properties) to Signature:

2.Has a Request entity have collection of Signature, which each Signature has Signature Type:

Was it helpful?

Solution

Model 1

This model pretty much carves your business rules in stone. There can only be three types of signatures and there can only be one each. Any change in these rules requires a database change, which is always a pervasive change.
Apart from that, there's a potential pitfall when you work with disconnected entities that you want to re-attach to a context. If one (or two) of the Signatures are the same (business rules permitting) you must heed the exception that two entity keys are added twice.

Model 2

This gives more freedom (extensibility), but that means that you need coded business rules to enforce the rules I mentioned for Model 1. On the other hand, it would allow more people to approve a request, for example.
Maybe an even better model would be to make SignatureType a flagged enum, so a signature can have multiple types and the signatures don't have to be repeated (again: the business rules permitting). This would avoid the potential multiple key exception I mentioned with Model 1.

So I would prefer model 2 (with flagged enum), because I like to express business rules in code, not in database constraints.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top