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.

Thanks
alevin16Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
Vehicles
   VehicleType (int)
   NumWheels (int)

The object model could have a base class:
Vehicle

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.
0
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!!
0
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:
http://www.di-mgt.com.au/classes.html

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>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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!
Andy
0
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 :-).
0
alevin16Author Commented:
Thank you thank you thank you!!!!  This was GREAT!
0
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!
0
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
0
Kyle AbrahamsSenior .Net DeveloperCommented:
Thanks all.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.