Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8218123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:40:57+00:00 2026-06-07T12:40:57+00:00

I’d like peoples opinion about the concept on Data Modeling Vs SQL (OOP Vs

  • 0

I’d like peoples opinion about the concept on Data Modeling Vs SQL (OOP Vs Select Statement) on the following matter:
When studying MVC and OOP concepts, it’s easy to see a natural form of things like in the follow:

<php? | <% | <#

Class Country{
     _name:String;
     _language:String;      
}

Class Estate{
     _name:String;
     _country:Country;
}

?> | % | #>

The point that I’m trying to get is a simple parent-child relation. Now, as I’ve seen working on ExtJS + PHP and JSF 2.0 (Java using Converter), it’s quite common to see a DAO (Data Access Object) being defined sort of like this:

Abstract class CountryDAO{
     public function getCountry();//This function returns an ArrayList.
     public function getCountryById(countryId:Integer);//This function returns a Country Object;
     ...
}

Class EstateDAO{
     public function getEstate(){
         $sql = "SELECT * FROM tbl_estate";
         //[your favorite way to comunicate with the database here]
         //Declare an ArrayList or something to store the result:
         $arrayList;
         while($result = $ResultSet.next()){
              $obj = new Estate();
              $obj->name = $result['name'];
              $obj->Country = new CountryDAO().getCountryById($result['country_id']);
              $arrayList->addItem($obj);
         }
     }
}

Sorry for mixing language syntaxes, I’m trying not to get too attached to language, just the concept

Now to finalize my thoughts: That is the right concept, according to theory. Personally, I don’t think it’s right to disagree with it since it’s the logic of the thing. But as in practice, the real world don’t ever shine as you want, what I see from that:

If I have 10 Estates, I’ll have 11 SQL Statements being executed on a Hard Disk level (which according to Operational System’s theory, it’s the slowest of all sorts of stored memory).

If I have 100 Estates, I’ll have 101 SQL Statements being executed.

If I have n Estates, I’ll have n+1 SQL Statements being executed.

My final point: I think that can be a real pain if you’re modeling a data entity that might have thousands of records. Because of that line of thought, I refused to use this kind of design logic while working with Flex + PHP. But now that I’m trying to build an application that will have both Flex and ExtJS as viewers and PHP as Server-Side, I just wanna be sure that I’m not choosing the hardest path for insignificant reason. Is it safer not to respect this MVC/OOP logic? Am I exaggerating? What do you think about SQL Vs Data Model on OOP?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:41:00+00:00Added an answer on June 7, 2026 at 12:41 pm

    I would suggest to stay away from DAO implementations which directly map onto a DB table. You instead should look into data mapper pattern.

    Basically the idea is, that, within the model layer, you separate business logic into domain objects and DB interaction into data mappers. This way , when you need to fetch a collection of items (like details of 100 estates ), the mapper performs only 1 or 2 queries, and dumps the data in your domain object, which deals with collections.

    And each mapper can easily deal with more the one DB table. The goal for mapper is to take domain object and interface it with storage. There is not law which says that your domain object can use only one table.

    In any case, the MVC design pattern has nothing to do with where you store the information. It only deals with separation of user interface and domain business logic. The SQL interaction ( if you even use SQL database and not some other data source ) is buried deep inside the model layer.

    I would strongly recommend for you to read this article: GUI Architectures by Martin Fowler.

    Also, if you are mostly dealing with PHP, you might find this comment useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.