Object Model vs Data Model

Posted on 2014-07-29
Medium Priority
Last Modified: 2014-07-30
Hello All

I was hoping someone could explain Object Model vs Data Model to me on a simple level.  Here is a situation we are in.  I have an Access database that is linked to another program (ODBC connection) so that I can add/edit/delete data in the other program.  I was told the way I am doing this is the data model and that I should be connecting via an object model (sorry if I am using the terms wrong).

From what little research I did it looks as if the object model just does more data validation than the data model (and that the object model deals with business logic).  Could I actually be interacting with this other program like an object model because on my forms I include all the code that handles the business logic.

Once again I am sorry if I sound like an idiot by using the terms wrong but I be just a simple Access programmer.

Question by:alevin16
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 40227938
on a High Level the Data Model simply spells out the tables and the fields within those tables.

The object model is more about the object oriented side of things (eg: classes and what not).

So for example:

you might have a table called vehicles in your database.
   VehicleType (int)
   NumWheels (int)

The object model could have a base class:

with Car inheriting from Vehicle
and Truck also inheriting from Vehicle.

They might be implemented completely different, but still refer back to the vehicle table in data model.

I hope that helps.

Author Comment

ID: 40227958
I like how you explained the data model in high level (it really helped!), but I have a question.  Would the VBA programming I did for the forms be the business logic?  I see how the Data Model would define a particular field as text but the VBA programming I did could restrict entry to be an email address (as an example), so would this be more like the Object Model?  

Sorry again for the confusion.  You really are helping me understand it! (I have to admit though that I really do NO Object Oriented Programming)

Thanks again!!
LVL 40

Accepted Solution

Kyle Abrahams earned 2000 total points
ID: 40227989
OOP (object oriented programming) can be a pain in the neck to get your head around, especially if you don't  do it.

Business logic is business logic . . . and that can be implemented in the object model or in the data model.

So going back to the vehicle example:
The business logic says for cars we want to ensure that you can only have 4 wheels.
For trucks it can be 4,8,12, or 18  (not accurate I'm just making it up, but that's my business logic).

I could do a trigger to implement that logic, and say delete data that doesn't meet that criteria
I could write those rules in the object model (eg: when I create my car class) to say that I only take 4 wheels.

So is the vba programming you did business logic?  It can be.  If you enforce rules that the users put on you then sure.

The VBA code I'm sure is also taking data from the fields and putting it in the database.  But that's not really business logic per say as it is more making everything wire up so that it works.

The object model is it's own stand alone thing.  Think about it. . . what is an email address?  It's a set of text that follows a set of rules.  (must have 1 or more characters, followed by an @ symbol, followed by more characters and then ending in a valid domain).

If you were to create a class that implements those rules, that would be the object model.   When I'm programming in classes I visualize that I'm creating a real thing (even though it's in cyber space).  I put myself in the middle of that thing and build it.  My "world" begins when the constructor is called, and I only "know" and care about whatever I want my thing to know and care about.  I keep it disconnected from the outside application.

When I'm done with the class I then use that class in my application, but the code for my class lives in the object model . . . and then I'm invoking (using) that class to do things that may or may not effect business logic.

More on classes here:

No need to apologize about the confusion . . . it's confusing as anything!  I'm just glad the analogies are helping you understand it all.  Feel free to keep asking until you think you have a solid grasp.  <joke> Then don't worry when you lose all of the understanding again . . . it likes to go out for walks and then come back. </joke>
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI


Author Comment

ID: 40228006
WOW where were you a few years ago when I walked out of a class on this.  I could have used you!  This is becoming very clear and I am really happy you are putting up with my "stupid" questions.

Ok so let me ask you this.  I connect to that program (I mentioned before) via Access (ODBC) there are people working on another program and they are telling the boss that their program is superior because it uses the Object Model to access and work with the data.  They say their method keeps the data in that main program "pure" and "clean" as opposed to mine.  If I use VBA to restrict what data goes into a particular field am I not doing the same thing but just in a different place?  As you say you have everything in your class (which probably makes it a hell of a lot easier to fix when things go wrong) and I just have it all in the code of the form.

The boss is the kind of guy who gets suckered into new and shiny things.  I have no clue how this man makes his money (he is the owner and a multimillionaire).  

Thank you again!
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 40228060
I hear you.

Yes you are essentially doing the same thing.  Again, whether the business rules are implemented in the "data layer" or "object layer" as long as they are implemented correctly at the end of the day it doesn't really matter.  (There are pros and cons for each).

I would first test the hell out of it and challenge them to break the form and insert bad data.

The only other caviat I would throw out there is if someone could bypass your VBA somehow . . . I know there were ways of compiling the project as an add-in or stand alone running app so that it would be less probably someone could do this.

If you have any other questions feel free to ask.  If not then good luck with your boss :-).

Author Comment

ID: 40228105
Thank you thank you thank you!!!!  This was GREAT!

Author Comment

ID: 40228152
I've requested that this question be closed as follows:

Accepted answer: 0 points for alevin16's comment #a40228105

for the following reason:

This was terrific!  The answers were explained in a way I could understand and he was extremely patient with my questions.  I cannot thank him enough!

Author Comment

ID: 40228175
I am sorry about that.  I did not realize that.  Yes he is the one who should get the credit and the points
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 40229247
Thanks all.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question