Results 1 to 4 of 4
Thread: terminology of ORM
Apr 24, 2014, 02:57 #1
terminology of ORM
I need some explanation about terminology of ORM and OOP. What do 'domain' and 'model' mean in this area?
Apr 24, 2014, 07:39 #2
- Join Date
- Nov 2003
- Huntsville AL
- 4 Post(s)
- 1 Thread(s)
That is a pretty broad question but here is a beginning of an answer.
First, don't separate domain and model. Instead, think in terms of a domain model which tries to represent whatever problem you are trying to resolve.
For example, in my sports game schedule system I have a Game object. A Game has 2 or more teams as well as 0 or more officials. So my domain model consists of Game, GameTeam and GameOfficial objects. These are simple plain php objects which contain some business logic.
I need to store games in a sql database. That is where an ORM layer comes in. By setting up some mapping files, I can save Game to a games table, GameTeam to a game_teams table etc and perserve the relations between them. Another object called GameRepository provides the link between my application and the database.
$game = $gameRepository->find(1);
echo $game->getHomeTeam()->getName(); // Echos the name of the home team for game #1.
$games = $gameRepository->findAllGamesForTeam('Auburn Tigers');
Apr 24, 2014, 08:05 #3
Thanks for nice explanation.
Apr 24, 2014, 11:46 #4
- Join Date
- Apr 2013
- 6 Post(s)
- 2 Thread(s)
Well 'domain' is actually just a synonym for 'business', to many people domain logic = business logic and domain model = business model. Model is a bit more difficult to explain, its an object with identity and the object in which the business logic come from. Hopefully this clears up your confusion, its indeed hard to grasp at times. XD