Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modeling People/Company Roles

Ive been working on a project which handles jobs for a home maintenance service, but Im having a difficult time modeling the roles that different people and companies play. If it matters the system is written using zendFramework, with mySql as the data storage.

Ill do my best to explain but I am not to well versed in the language of data modeling.
the end user of this system is a Maintenance Company I will call HammerTime in the following examples. This is what I have so far:

WorkOrderRequests come in from two primary sources: Source 1: Resident>>requestWorkOrder>>PropertyManagementCompany>>requestWorkOrder>>HammerTime

Source 2: HomeOwner>>requestWorkOrder>>HammerTime

I think of all of these entities as customers, but only PropertyManagementCompanies and HomeOwners are "direct" customers which will receive invoices. Also a resident can be a HomeOwner if they own the property they reside in. Also to add another layer of business logic on top this, all Residents belong to a Property and all requests from a Resident to a PropertyManagementCompany are mediated by a PropertyManager

When WorkOrderRequests come in to HammerTime they are stored as WorkOrders and then are handled in a few different ways.

Handled 1: HammerTime>>assignWorkOrder>>Employee

Handled 2: HammerTime>>contractOutWorkOrder>>ServiceVendor

I think of these entities as the workers and they seem to be easier to model.

The problem is that the I would like to be able to grant access to all of these entities to the system based on their role types. In my mind I would like to group them all under a Member abstract superclass which could be subclassed by two more abstract classes Person and Company. then the Person and Company could further be subclassed by more concrete classes like Employee or PropertyManagementCompany etc..

Where would a Property fit in as it is not a person or a company. I guess maybe it would be a Member

I have a feeling I am completely missing something as something just doesnt feel right. So any ideas, or pointers would be greatly appreciated.

like image 850
John Avatar asked Jan 28 '26 00:01

John


1 Answers

I don't know php or Zend at all, but you might want to look at the "Party-Role" Pattern. (Just google, see e.g. (1)(2)(3)).

In your scenario Person & Organisation are subtypes of Party. Employee, ServiceVendor, Resident, etc. are all subtypes of Role. There's a many:many relationship among Party & Role. You can define relationships as required among role subtypes. Assigning permissions should then become easy; each Party gains permissions for each role it is assigned to.

hth.

like image 166
sfinnie Avatar answered Jan 30 '26 16:01

sfinnie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!