When storing data, particularly when stored in a relational model, it's quite often better to make sure the data is properly normalized[0]. However, normalized data in the way that suits the data model might not be the more convenient way to operate on it from the perspective of your domain logic.
Additionally, the data types in your data model are limited by what your data layer supports, but on the domain side you might want to have richer data types.
ORMs make it easier to obtain the data in a shape and in types that are useful to you from a domain model perspective, while still storing the data in a way that's useful for the database side of things.
Example 1:
I want to store Users which have a `name` and `date_of_birth` property in a table. However, when operating on that object in the domain side, I might want to have instances of a User class which might expose a method such as `isOfLegalAge()`, which would let me know whether that user is old enough to, let's say, sign a mortgage contract.
A ORM makes it easier for me to get back an instance of a User class (which can have useful methods), instead of having to operate on a database row structure, which would give me strictly data.
Example 2:
A given Product, which has a `name` and a `price`, might be supplied by a Supplier, which has a `name` and an `location`. When fetching a user from a database, I might want to have an object in a shape such as:
However when I store it, a Product would have a reference to a `supplier_id`, which points to a row in the Supplier table. The supplier's location's city and country would be a city_id and country_id, each of which referencing a row in a City table and a Country table.
So from a data model representation it might look more like this:
Product {
id: number
name: string
supplier_id: number
}
Supplier {
id: number
name: string
location_id: number
}
Location {
id: number
city_id: number
country_id: number
}
City {
id: number
name: string
}
Country {
id: number
name: string
}
The ORM would map between these two representations.
Yep. I started reading the zerocarb subreddit more than a decade ago. And decided to try carnivore (with a few plant foods) August, 2022. So far, so good.
It's 2025, I've used PHP professionally maybe for a few months out of the last 20 years, the languages I use mostly don't have `::` as a token, and still, I find it really hard to refer to it as anything other than Paamayim Nekudotayim :-)
Less good, more fun. To 'prove' that you were over 18 you had answer a series of multiple choice questions [1] about pop culture that most kids almost certainly wouldn't know. Pre internet, finding the answer was surprisingly hard without asking an adult. The main result was that 10 year old me knew a surprisingly large number of obscure facts of about US culture, like who Spiro Agnew was and that Ronald Reagan once starred in a movie with a monkey.
Eventually we found out that you could press some magic key combination to skip the question all together.
Initially when I moved to Germany I thought it was a bit of a hassle to have to go to the post office for PostIdent; now I actually miss the elegance and privacy of that system in other countries.
Learning things for fun and not just for profit. Physical development, learning a new sport. Spiritual development, meditating, observing. Engaging in arts, creating, exploring. Helping the less fortunate, volunteering, teaching. Traveling, learning about different cultures, different languages. Cooking. Spending time in nature, watching animals, birds, mushrooms, sunsets. Photography. These are just some examples, the list is endless :-)
Personally I’ve grown a lot from gardening and weightlifting. Having children made me more human.
Additionally, the data types in your data model are limited by what your data layer supports, but on the domain side you might want to have richer data types.
ORMs make it easier to obtain the data in a shape and in types that are useful to you from a domain model perspective, while still storing the data in a way that's useful for the database side of things.
Example 1:
I want to store Users which have a `name` and `date_of_birth` property in a table. However, when operating on that object in the domain side, I might want to have instances of a User class which might expose a method such as `isOfLegalAge()`, which would let me know whether that user is old enough to, let's say, sign a mortgage contract.
A ORM makes it easier for me to get back an instance of a User class (which can have useful methods), instead of having to operate on a database row structure, which would give me strictly data.
Example 2:
A given Product, which has a `name` and a `price`, might be supplied by a Supplier, which has a `name` and an `location`. When fetching a user from a database, I might want to have an object in a shape such as:
However when I store it, a Product would have a reference to a `supplier_id`, which points to a row in the Supplier table. The supplier's location's city and country would be a city_id and country_id, each of which referencing a row in a City table and a Country table.So from a data model representation it might look more like this:
The ORM would map between these two representations.[0] https://en.wikipedia.org/wiki/Database_normalization