I have Joined Tables Inheritance in my database : a Client table that can be a Company or a Person. I need to create an account for the client but only one if it's a person and one or many if it's a company. I also have users for backoffice that also need an account. So I tried this but I'm not sure if it's a good idea or not. So is it a good idea or not pls ?
Edited Thanks to The Impaler : enter image description here
CodePudding user response:
Your model is already pretty good, but you should fix/improve the following issues:
- By setting the multiplicity 1 at the sides of
Company
andPerson
, the current model states that each client must be associated both with a company and a person! You have to fix this by changing the multiplicity to 0..1 and possibly add an invariant that requires each client to be either a company or a person (in a constraint box attached to the class rectangle). - Since, in general, not every company and not every person is a client, you should either change the multiplicities of their association ends at the
Client
side to 0..1 or rename these classes/tables toCompanyClient
andPrivateClient
. - In UML, the names of classes should not be underlined.
- In UML, the standard ID attribute(s) of a class (called primary key in databases) have to be desginated by "{id}" appended at the end of the attribute declaration line, and not by underlining the attribute(s) concerned.
- It's not good practice in UML, to redundantly represent reference properties both with associations and in the form of attributes, as you do with your #-prefixed attributes. Just drop these non-UML syntax attribute declaration lines.
- Better rename your
AccountCompany
class toAccountsByCompany
.