Register to get access to free programming courses with interactive exercises

ORM Key Aspects of Web Development in Python

Programmers develop each piece of software for a specific domain, for example:

  • An analytics system might work with view, session, funnel, and cohort
  • The concepts will be different in an online store — product, category, and payment gateway

Together they form the domain ontology. You can find the term category model in some sources. It is the same as ontology. In addition to the concepts themselves, ontologies include descriptions of their relationships. For example, the User entity relates to the Purchase entity in a one-to-many relationship. It means users can make any number of purchases, but each purchase belongs to only one user.

The domain model is the basis for communication and understanding between team members. It doesn't depend on the programming language or programming in general. It doesn't matter who is communicating — programmers with each other or programmers with customers, managers, or designers, it's all the same. You work with the domain's entities and relationships and the business rules used in that program.

Such rules may include automatically including a discount when ordering a certain amount of goods:


It's important to understand that the model reflects only a part of the domain in some detail. And the model can vary in programs written by different developers, even if they're from the same field.

Some domains have a set of fixed entities, relationships, and rules of operation. We can see it in accounting, for example. But there are also less formal areas where there are even more possibilities. Here are some examples from Hexlet. The number of entities is more than a hundred, the number of links is several hundred, and the number of rules is difficult to count. There are so many of them too.

We create a data model in code based on the domain model. We construct entities and define their relationships. Then we build a working code that operates on the entities based on requirements and business rules. You may be wondering how to map these entities to the database where they're stored.

The easiest way is to create a table for each entity and link them with foreign keys. Most projects do this. We can do it by the Object Relational Mapper (ORM) — a data framework.

The ORM helps describe entities and their relationships and determines how the entity is mapped to the database (usually semi-automatically). The ORM takes care of a part of the work:

Sign up

Programming courses for beginners and experienced developers. Start training for free

  • 130 courses, 2000+ hours of theory
  • 1000 practical tasks in a browser
  • 360 000 students
By sending this form, you agree to our Personal Policy and Service Conditions

Our graduates work in companies:

<span class="translation_missing" title="translation missing:">Bookmate</span>
<span class="translation_missing" title="translation missing:">Healthsamurai</span>
<span class="translation_missing" title="translation missing:">Dualboot</span>
<span class="translation_missing" title="translation missing:">Abbyy</span>
Suggested learning programs
Developing web applications with Django
10 months
from scratch
under development
Start at any time

Use Hexlet to the fullest extent!

  • Ask questions about the lesson
  • Test your knowledge in quizzes
  • Practice in your browser
  • Track your progress

Sign up or sign in

By sending this form, you agree to our Personal Policy and Service Conditions
Toto Image

Ask questions if you want to discuss a theory or an exercise. Hexlet Support Team and experienced community members can help find answers and solve a problem.