Suppose I have a class named A. This class has a attribute which is a class itself, but it maybe various classes, sometimes B1,sometimes B2 and �.
So,I thought the best model might be like this:
![]()
[/img]
It�s good, because if another class like B3 needed to be added, It�s simple just inherit it from C class.
But the subject is B1, B2 and B3 are not type of C naturally .So what is problem?
Suppose we have similar situation for Z class. it has a attribute which is a class, and might be various class, sometimes B1,Sometimes D1,�..Like this:
![]()
[/img]
It means B1 is inherited from C and E.
Here we have 2 problems:
1-I had to model multi inheritance, that not supporting in my implementing environment and I have to use trick and
pattern to do it, and it made more complex.
2-when I want to convert my class diagram to Data model:
I will have a C table with CID for Primary key. And I have B1 and B2 tables too. Related class of them inherited from C class, and then CID is primary key for B1 and B2 tables too.
This story goes for E table and, B1 and D1 Tables too. But in this case B1 table have 2 primaries key CID and EID.
What should I do?