OOP data storage vs. SQL calls

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Victor Fees

    #1

    OOP data storage vs. SQL calls

    I have a general question for which I would like to get some general input
    from the online community.

    I'm building an asp.net web application that will make extensive use of a
    SQL Server 2K database. One of the relationships in this database is many
    Tasks to a 1 Project. I can see two basic ways to manage this in my web
    application: The first is by creating a Project class and a Task class,
    and talking directly to the database with either -- meaning that on each
    page where I need data about either a Project or a Task, I make the stored
    procedure calls and add, modify, or delete the data appropriately.

    The other is to use the IEnumerable interface so that I can do clever
    things like Project.Tasks.A dd() and Project.Tasks.M odify(), etc. But, in
    this model, it seems to make more sense to get all the necessary data upon
    instantiation of the Project class, and then carry it around in a Session
    object, and make database calls as I need to in order to keep the class and
    the database in sync.

    OK, so here's the question -- which is more efficient, and is there a point
    of diminishing returns for the preferred answer. In short, does it make
    more sense to have more database calls (potentially every page), or to have
    one big one, and carry the enumerated object around in Session, making
    calls only as necessary.

    Please note that I realize that number of concurrent users, number of
    layers in the architecture, etc. are all factors in making the decision . .
    .. I'm looking for an "all other things being equal, x is more efficient,
    and here's why . . . "

    Anyone got an opinion on this? Any input is appreciated.

    Thanks,
    Vic Fees
  • dd

    #2
    Re: OOP data storage vs. SQL calls

    The rule of thuimb is:

    1. WEB application (N-tiered) -> use DB for caching.
    2. Client/Server -> user memory for caching.

    This an old problem that any design faces at the very beginning, i.e. where
    to cache data.
    If you want your WEB application to be scalable and perform well you will be
    better off using DB for caching, although it does not exclude caching of
    small amount of data in Session object or ViewState.
    DB calls are not a problem nowadays at all, networks are fast. BTW, I have
    seen projects where people were trying to implement Client/Server approach
    to WEB enabled applications, and they usually failed miserably.

    "Victor Fees" <vfees_spamless @seventhfloorin c.com> wrote in message
    news:Xns93C3490 5CE346vfeesseve nthfloorinc@207 .46.248.16...[color=blue]
    > I have a general question for which I would like to get some general input
    > from the online community.
    >
    > I'm building an asp.net web application that will make extensive use of a
    > SQL Server 2K database. One of the relationships in this database is many
    > Tasks to a 1 Project. I can see two basic ways to manage this in my web
    > application: The first is by creating a Project class and a Task class,
    > and talking directly to the database with either -- meaning that on each
    > page where I need data about either a Project or a Task, I make the stored
    > procedure calls and add, modify, or delete the data appropriately.
    >
    > The other is to use the IEnumerable interface so that I can do clever
    > things like Project.Tasks.A dd() and Project.Tasks.M odify(), etc. But, in
    > this model, it seems to make more sense to get all the necessary data upon
    > instantiation of the Project class, and then carry it around in a Session
    > object, and make database calls as I need to in order to keep the class[/color]
    and[color=blue]
    > the database in sync.
    >
    > OK, so here's the question -- which is more efficient, and is there a[/color]
    point[color=blue]
    > of diminishing returns for the preferred answer. In short, does it make
    > more sense to have more database calls (potentially every page), or to[/color]
    have[color=blue]
    > one big one, and carry the enumerated object around in Session, making
    > calls only as necessary.
    >
    > Please note that I realize that number of concurrent users, number of
    > layers in the architecture, etc. are all factors in making the decision .[/color]
    ..[color=blue]
    > . I'm looking for an "all other things being equal, x is more efficient,
    > and here's why . . . "
    >
    > Anyone got an opinion on this? Any input is appreciated.
    >
    > Thanks,
    > Vic Fees[/color]


    Comment

    • dd

      #3
      Re: OOP data storage vs. SQL calls

      Actually, I can give you an example that kills your solution #2 (keeping
      state in Session object).
      Let's imagine that you have implemented this solution. I am a user who is
      working with data and entering some new data. Then in the middle of my work
      my phone rings, and I spend 25 min talking to somebody on the phone. When I
      get back to the application, all my data is gone, since my session has
      expired. I did not even have a chance to save it.
      You can increase Session timeout, but where is the limit? And by increasing
      session timeout you will load your WEB server with lots of data that you may
      not need. This solution is not scalable.

      "dd" <aaa@aaa.com> wrote in message
      news:OgaUa.1014 0$Wh.1072542@ne ws20.bellglobal .com...[color=blue]
      > The rule of thuimb is:
      >
      > 1. WEB application (N-tiered) -> use DB for caching.
      > 2. Client/Server -> user memory for caching.
      >
      > This an old problem that any design faces at the very beginning, i.e.[/color]
      where[color=blue]
      > to cache data.
      > If you want your WEB application to be scalable and perform well you will[/color]
      be[color=blue]
      > better off using DB for caching, although it does not exclude caching of
      > small amount of data in Session object or ViewState.
      > DB calls are not a problem nowadays at all, networks are fast. BTW, I have
      > seen projects where people were trying to implement Client/Server approach
      > to WEB enabled applications, and they usually failed miserably.
      >
      > "Victor Fees" <vfees_spamless @seventhfloorin c.com> wrote in message
      > news:Xns93C3490 5CE346vfeesseve nthfloorinc@207 .46.248.16...[color=green]
      > > I have a general question for which I would like to get some general[/color][/color]
      input[color=blue][color=green]
      > > from the online community.
      > >
      > > I'm building an asp.net web application that will make extensive use of[/color][/color]
      a[color=blue][color=green]
      > > SQL Server 2K database. One of the relationships in this database is[/color][/color]
      many[color=blue][color=green]
      > > Tasks to a 1 Project. I can see two basic ways to manage this in my web
      > > application: The first is by creating a Project class and a Task class,
      > > and talking directly to the database with either -- meaning that on each
      > > page where I need data about either a Project or a Task, I make the[/color][/color]
      stored[color=blue][color=green]
      > > procedure calls and add, modify, or delete the data appropriately.
      > >
      > > The other is to use the IEnumerable interface so that I can do clever
      > > things like Project.Tasks.A dd() and Project.Tasks.M odify(), etc. But,[/color][/color]
      in[color=blue][color=green]
      > > this model, it seems to make more sense to get all the necessary data[/color][/color]
      upon[color=blue][color=green]
      > > instantiation of the Project class, and then carry it around in a[/color][/color]
      Session[color=blue][color=green]
      > > object, and make database calls as I need to in order to keep the class[/color]
      > and[color=green]
      > > the database in sync.
      > >
      > > OK, so here's the question -- which is more efficient, and is there a[/color]
      > point[color=green]
      > > of diminishing returns for the preferred answer. In short, does it make
      > > more sense to have more database calls (potentially every page), or to[/color]
      > have[color=green]
      > > one big one, and carry the enumerated object around in Session, making
      > > calls only as necessary.
      > >
      > > Please note that I realize that number of concurrent users, number of
      > > layers in the architecture, etc. are all factors in making the decision[/color][/color]
      ..[color=blue]
      > .[color=green]
      > > . I'm looking for an "all other things being equal, x is more efficient,
      > > and here's why . . . "
      > >
      > > Anyone got an opinion on this? Any input is appreciated.
      > >
      > > Thanks,
      > > Vic Fees[/color]
      >
      >[/color]


      Comment

      Working...