Now that we know what domain modeling is, and the basics on how to do it, it's time to look at larger, more real-world examples.

A Customer Relationship Management (CRM) system is one that allows users (typically sales teams) to keep track of companies/contacts and the interactions (emails, sales calls, in-person meetings, etc.) the user has with each contact. If you've worked in sales before, chances are you've used some kind of CRM system – e.g. Salesforce, Zoho, Freshdesk, Pipedrive, or about 1000 others. In this case study, we're going to create the domain model for our own simple CRM.

Here are the user stories and wireframes:

  • As a salesperson, I want to maintain a list of contacts (along with each contact's name, email address, and phone number), so I know how to reach each person.
  • As a salesperson, I want to be able to log each activity (e.g. calls/emails, with a date/time it occurred and my notes.) I have with a contact, so I can keep a diary of all the communication I have with each person.
  • As a salesperson, I want to manage a list of companies (name), so I know all the companies we sell to.
  • As a salesperson, I want to associate contacts with a company, so that I can get a company-wide view of my sales team's communication with all the people at a company.
  • As a salesperson, I want to maintain my own contact information (first/last name and email address), so that other members of the sales team know who I am.

What real-world entities are we dealing with? Once those are determined, what relationships or join models are needed to connect the dots?

Jot your thoughts down on paper or tool of your choice (sometimes visual is a better way to get started than a bunch of CREATE TABLE statements), then write the script to create the actual SQLite database.

Go Further

Once you've designed a database to support the initial user stories and wireframes, here's a challenge to flesh out our domain model.

Additional user stories:

  • As a salesperson, I want to maintain a list of industries, so that I can see how my sales team is performing across the different industries we do business with.
  • As a salesperson, I want to indicate a company's industries (1 or more), so I can categorize the companies we sell to by industry.

Updated wireframe:

Wireframe for the account view