Reputation: 678
Hi I have a question about some circular relationships that I am facing with my database design . I read a few more similar questions but couldn't solve my problem, so here is my class diagram :
and here is the logic:
the value should be saved according to the fieldType ( date , char , long , double... )
However, from a database architect perspective, this circular relation is incorrect since it can results in integrity problems:
Should you have any idea how to deal with this, please be welcomed to comment.
Thank you in advance for your help.
Upvotes: 3
Views: 2875
Reputation: 5864
Here the situation is even simpler than in your other similar question. It is clear that bottom two classes describe the abstract document structure, while the top two classes describe concrete documents.
Abstract elements should never depend on concrete ones, so just make two vertical associations unidirectional and point them towards abstract classes. This will break the circular dependency neatly.
In addition, I would further refine your model:
UPDATE:
Upvotes: 1
Reputation: 7440
I can't actually see the aim of your modeling. It seems to me you are mixing meta-elements ( DocumentType and DocumentField) with modeling elements instances of the meta-elements (Document and FieldValue).
What is the semantics of the Document-->DocumentType relationship ? is it an "isA" relationship? if so why don't you use extension/generalization (inheritance) or interface realization (implementation)?
Why do you need the inverse relationship DocumentType-->Document? if You could avoid it you wouldn't have the circular relationship.
[Update] Why don't you rename DocumentType in AbstractDocument and make it an abstract class. Then replace the association from Document to DocumentType with an extension (generalization) Finally create a 1..* association from AbstractDocument to itself
[Update2] Also consider that according to your explanation the association from Document to DocumentType has different sematnics and thus is different (another association) from the association that goes from DocumentType to Document
Upvotes: 0