Last time I defined such concepts: BusinessEntityType, BusinessEntity, BusinessEntityTypeRule.
So, by operating these concepts, we can define almost any business-system. But we still haven’t discuss how to store data. For example address of Client, phone number of Manager, names, last names, all data.
Almost all CRM are using databases for storing data. For storing data for each entity type I’ll use table in database. BusinessEntityType should be extended:
Entity BusinessEntityType(id, name, tableName)
In this way we can define for each type of BusinessEntity in which table data should be stored. Any DataBase Architect/Analyst can create proper tables, according to business models.
Let’s add a few more concepts. As I said before, we have Managers, Clients. We are working somehow with Clients — we should have entities Contracts, Invoices, Payments. Contract may be active, canceled, scheduled, ended; Invoice can be new, payed, canceled, nullified, partially payed, over-payed; Payment can be pending, approved, finished, canceled, returned. All of this represent a new entity:
Entity BusinessEntityStateType(id, name, business_entity_type_id)
With this concept, we can now define for each BusinessEntity a required set of states. But what if some BusinessEntity have two or more independent states? For example, color and weight, or any else?
Entity BusinessEntityStateType(id, name, business_entity_type_id, table_column_name)
With only one additional table_column_name, we created a way to any entity have as many states as we need. (If you like creative and abstract thinking, you should notice, that there is no difference between «state» column and any finish-state column; so BusinessEntityStateType could be used a bit wider, and renamed to AvailableColumnValue.)
Okay, we now can define business entities, we can define some available states for each entity, we can specify for each state all values, what’s next?
Many of system operating by CRUD ideology. CRUD — is 4 freedoms, Create, Retrieve, Update, Delete. For managing impersonal data in database it’s surely enough. But it’s not enough for me, in this CRM system.
I want define a new entity, named BusinessAction. It will be not complicated entity, but with sign of usage of some code, and with specification of on which BusinessEntityType this action defined:
Entity BusinessAction(id, name, code_function, type_id)
What does it mean for us? We can now define CRUD actions for each entity, and we can define additional, business-specific actions. For example — «change owner action», «change Invoice state», «change Payment state», etc. After we’ll define these actions, we can use permission/acl system and specify rights for each manager to each object.
Stay tuned, next time I’ll cover permissions and rights system!