Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is ORM considered good but "select *" considered bad?
    primarykey
    data
    text
    <p>Doesn't an ORM usually involve doing something like a select *?</p> <p>If I have a table, MyThing, with column A, B, C, D, etc, then there typically would be an object, MyThing with properties A, B, C, D. </p> <p>It would be evil if that object were incompletely instantiated by a select statement that looked like this, only fetching the A, B, not the C, D:</p> <p>select A, B from MyThing /* don't get C and D, because we don't need them */</p> <p>but it would also be evil to always do this:</p> <p>select A, B, C, D /* get all the columns so that we can completely instantiate the MyThing object */</p> <p>Does ORM make an assumption that database access is so fast now you don't have to worry about it and so you can always fetch all the columns?</p> <p>Or, do you have different MyThing objects, one for each combo of columns that might happen to be in a select statement?</p> <p><strong>EDIT: Before you answer the question, please read Nicholas Piasecki's and Bill Karwin's answers. I guess I asked my question poorly because many misunderstood it, but Nicholas understood it 100%. Like him, I'm interested in other answers.</strong></p> <hr> <p>EDIT #2: Links that relate to this question:</p> <p><a href="https://stackoverflow.com/questions/18655/why-do-we-need-entity-objects">Why do we need entity objects?</a></p> <p><a href="http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx" rel="nofollow noreferrer">http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx</a>, especially the section "The Partial-Object Problem and the Load-Time Paradox"</p> <p><a href="http://groups.google.com/group/comp.object/browse_thread/thread/853fca22ded31c00/99f41d57f195f48b" rel="nofollow noreferrer">http://groups.google.com/group/comp.object/browse_thread/thread/853fca22ded31c00/99f41d57f195f48b</a>?</p> <p><a href="http://www.martinfowler.com/bliki/AnemicDomainModel.html" rel="nofollow noreferrer">http://www.martinfowler.com/bliki/AnemicDomainModel.html</a></p> <p><a href="http://database-programmer.blogspot.com/2008/06/why-i-do-not-use-orm.html" rel="nofollow noreferrer">http://database-programmer.blogspot.com/2008/06/why-i-do-not-use-orm.html</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload