Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Modeling Milk: A Discussion on Domain Modeling

DZone's Guide to

Modeling Milk: A Discussion on Domain Modeling

This article includes an interesting analogy on domain modeling.

· Database Zone ·
Free Resource

RavenDB vs MongoDB: Which is Better? This White Paper compares the two leading NoSQL Document Databases on 9 features to find out which is the best solution for your next project.  

I recently had a discussion at work about the complexity of modeling data in real-world systems. I used the example of a bottle of milk in the discussion, and I really like it, so I thought it would make for a good article.

Consider a supermarket that sells milk. In most scenarios, this is not exactly a controversial statement. How would you expect the system to model the concept of milk? The answer turns out to be quite complex, in practice.

To start with, there is no one system here. A supermarket is composed of many different departments that work together to achieve the end goal. Let’s try to list some of the most prominent ones:

  • Cashier
  • Stock
  • Warehouse
  • Product catalog
  • Online

Let’s see how each of these think about milk, shall we?

The cashier rings up a specific bottle of milk, but aside from that, they don’t actually care. Milk is fungible (assuming the same expiry date). The cashier doesn’t care which particular milk cartoon was sold, only that the milk was sold.

The stock clerks care somewhat about the specific milk cartoons, but mostly because they need to make sure that the store doesn’t sell any expired milk. They might also need to remove milk cartoons that don’t look nice (are crumpled, etc).

The warehouse cares about the number of milk cartoons that are in stock on the shelves and in the warehouse, as well as predicting how much should be ordered.

The product catalog cares about the milk as a concept, the nutritional values, its product picture, etc.

The online team cares about presenting the data to the user, mostly similar to the product catalog until it hits the shopping cart/actual order. The online team also does a prediction based on past orders and may suggest shopping carts or items be purchased.

All of these departments are talking about the same “thing,” or so it appears, but it looks, behaves, and acts upon in very different ways.

Do you pay to use your database? What if your database paid you? Learn more with RavenDB.

Topics:
database ,domain model ,analogy ,complexity ,modeling ,domain

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}