Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 606
  • Last Modified:

Object Model vs Data Model

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.

  • 5
  • 4
1 Solution
Kyle AbrahamsSenior .Net DeveloperCommented:
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.
alevin16Author Commented:
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!!
Kyle AbrahamsSenior .Net DeveloperCommented:
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>
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

alevin16Author Commented:
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!
Kyle AbrahamsSenior .Net DeveloperCommented:
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 :-).
alevin16Author Commented:
Thank you thank you thank you!!!!  This was GREAT!
alevin16Author Commented:
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!
alevin16Author Commented:
I am sorry about that.  I did not realize that.  Yes he is the one who should get the credit and the points
Kyle AbrahamsSenior .Net DeveloperCommented:
Thanks all.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now