Using System Entity User and Extending It

0
Hello, Thanks in advance for the help.  I am getting started with Mendix and the amount of people that contribute to answering in this forum is amazing, truly thanks! I have a ProjectManagement module and I have two types of people.  External users are stored in an entity called Person. I want to assign "internal" users as well.  I am thinking it is best for the longevity of this to differentiate the two as (for example) only internal people can be Project Owners.  However, I want to store additional data about my users.  I want to store their address, Office Phone, Cell Phone, etc. as that will be used in certain forms I generate. How do I extend the built-in User entity?  Or should I be leaving that alone and is there a better way to do this? Right now I created an association to the system user entity, just not sure how to add attributes to it.
asked
5 answers
4

Hi Ivan,

if the extended data is used in the main process of your app; use a 1-1 association to account. This allows you to bind this data to their ability to login.  don't use inheritance for this. This is  further explained in this module https://gettingstarted.mendixcloud.com/link/module/37/lecture/338

Additionally take a look at this learning path. it will help your to build better domain models:

https://gettingstarted.mendixcloud.com/link/path/16

Rene

answered
1

Ivan,

You could use the user entity as generalization for your entities, then your internal and external users will enherit the attributes from the user entity.

For more information on inheritance this blog post is a nice starting point:

https://www.mendix.com/blog/working-with-inheritance-saving-you-time-and-sanity/

answered
1

Hi everyone,

 

Thanks for the great feedback.  Yes this did create a little confusion on my end as the recommendations are conflicting lol.

 

I was in the midst of watching the entire learning path on advanced data modeling so I decided best to finish that up first which I did yesterday.  Here is what I think I am going to do, happy to hear feedback on this.

  • Person (existing entity)
  • System Account Entity (already exists)
  • InternalPerson (new entity)
    • I am going to add an association to Person since they share all of the same attributes
    • 1-1 relationship with account so I can ensure that they are one and the same person.

 

If I understand it right I dont want an association with the account because I am not using majority of the attributes.  And it "is not an account" but an Internal Person "has an account"

 

By associating with person I can keep all of that data consistent and use it in my pages easily to see the "persons" that are both internal and not based on the specialization.

All of my "contacts" just remain in the peson entity as they are non-specialized.  

 

Hopefully that makes sense, if not def let me know!!!!

 

Thanks all and Happy New Years!

answered
0

Hi Ivan,

Based on your further input, I would go for the following domain model:

 

Since a InternalPerson is equal to a Person, but has more details. And a Person is not equal to an InternalPerson. Inheritance works. With this, you can Manage both Person and Internal as a Person, but the InternalPerson is specialized and can thus handled accordingly. 

The 1-1 association results in the possibility that one has a account. Both Person as InternalPerson can have an account. You can define in your own setup who will and who won't get an account.
If a Person will never have an account, than you could move the association to account to the InternalPerson. In that case only InternalPerson can have an account and Persons won't

 

Happy modeling new year!

answered
-1

Two bigtime contributors giving you two conflicting advises. How to pick the right one if you are only getting started with Mendix. Oh my...

Here is my two cents:

For the question 'use inheritance or a 1-1 relation?': That boils down to is-a or has-a.

  • An internal user is a person, so inheritance. Entity InternalPerson will be allowed to own a project.
  • An external user is a person, so inheritance. Entity ExternalPerson will not be allowed to own a project
  • An user has an account, so 1-1 relation.
  • An person has an address, so 1-1 relation.

Also see https://gettingstarted.mendixcloud.com/link/module/50/lecture/399

Btw. If you refer to something as 'External user' then name the entity the same: 'ExternalUser'. That keeps it self-explanatory.

answered